Skip to content

Commit

Permalink
chore: Set up code create dev and prod environments
Browse files Browse the repository at this point in the history
  • Loading branch information
alllenshibu committed Feb 29, 2024
1 parent 70e6630 commit 1017eaf
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/web-admin/src/components/ProtectedRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const ProtectedRoute = ({ children }) => {
const handleLogin = async () => {
loginWithRedirect({
authorizationParams: {
audience: 'https://core.techno.iedcmec.in/api',
audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
},
});
};
Expand Down
2 changes: 1 addition & 1 deletion apps/web-admin/src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Sidebar = ({ isOpen, onClose }) => {
<Box padding={4} height="100%" minWidth={50} width={80}>
<Box paddingY={4}>
<Text fontSize="4xl" fontWeight="bold">
techno
Event Sync
</Text>
</Box>
<SidebarContents />
Expand Down
8 changes: 4 additions & 4 deletions apps/web-admin/src/hooks/useFetch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const useFetch = () => {
'Bearer ' +
(await getAccessTokenSilently({
authorizationParams: {
audience: 'https://core.techno.iedcmec.in/api',
audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
},
})),
},
Expand Down Expand Up @@ -48,7 +48,7 @@ export const useFetch = () => {
'Bearer ' +
(await getAccessTokenSilently({
authorizationParams: {
audience: 'https://core.techno.iedcmec.in/api',
audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
},
})),
},
Expand Down Expand Up @@ -76,7 +76,7 @@ export const useFetch = () => {
'Bearer ' +
(await getAccessTokenSilently({
authorizationParams: {
audience: 'https://core.techno.iedcmec.in/api',
audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
},
})),
},
Expand Down Expand Up @@ -104,7 +104,7 @@ export const useFetch = () => {
'Bearer ' +
(await getAccessTokenSilently({
authorizationParams: {
audience: 'https://core.techno.iedcmec.in/api',
audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
},
})),
},
Expand Down
11 changes: 11 additions & 0 deletions packages/auth0-flows/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "auth0-flows",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
32 changes: 32 additions & 0 deletions packages/auth0-flows/src/add-user-to-database/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const axios = require('axios');

exports.onExecutePostUserRegistration = async (event, api) => {
try {
const { user } = event;

const userId = user.user_id;
const email = user.email;

const apiUrl = event.secrets.CORE_AUTH0_ACTIONS_API + '/api/auth/newuser';

const { data, status } = await axios.post(
apiUrl,
{
userId,
email,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + event.secrets.AUTHORIZATION_SECRET,
},
validateStatus: () => true,
},
);

if (status === 200) console.log(`Status: ${status} - Successfully added ${userId} to database`);
else console.log(`Status: ${status} - Failed to add ${userId} to database`);
} catch (error) {
console.error('Error calling API:', error.message);
}
};

0 comments on commit 1017eaf

Please sign in to comment.