Skip to content

Commit

Permalink
[migrate] replace GitHub OAuth with Auth0
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Feb 23, 2024
1 parent e5c6691 commit 8b96f61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions components/User/ServerSessionBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Icon } from 'idea-react';
import { faShieldHalved } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { observer } from 'mobx-react';
import { JWTProps } from 'next-ssr-middleware';
import { FC, HTMLAttributes } from 'react';
Expand All @@ -18,9 +19,10 @@ export const ServerSessionBox: FC<ServerSessionBoxProps> = observer(
<Button
variant="dark"
size="lg"
href={`${strapiClient.baseURI}connect/github`}
href={`${strapiClient.baseURI}connect/auth0`}
>
<Icon className="me-2" name="github" /> GitHub {i18n.t('sign_in')}
<FontAwesomeIcon className="me-2" icon={faShieldHalved} />
Auth0 {i18n.t('sign_in')}
</Button>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { buildURLData } from 'web-utility';

import { SessionUser, strapiClient } from '../../../models/User/Session';

export const getServerSideProps = compose(
export const getServerSideProps = compose<{ provider: string }>(
errorLogger,
async ({ query, res }) => {
async ({ params, query, res }) => {
const { body } = await strapiClient.get<{ jwt: string; user: SessionUser }>(
`auth/github/callback?${buildURLData(query)}`,
`auth/${params!.provider}/callback?${buildURLData(query)}`,
);
res.setHeader('Set-Cookie', `token=${body!.jwt}; Path=/`);

return { props: {}, redirect: { statusCode: 302, destination: '/' } };
},
);

const GitHubRedirection: FC = () => <></>;
const ProviderRedirection: FC = () => <></>;

export default GitHubRedirection;
export default ProviderRedirection;

1 comment on commit 8b96f61

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for open-hackathon ready!

✅ Preview
https://open-hackathon-lsk12u3fr-techquery.vercel.app

Built with commit 8b96f61.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.