[portal][feat] configure Next Auth's sign in route to point to custom login page

pull/528/head
Yangshun Tay 2 years ago
parent 0cdd5ac9a1
commit 9d0721c4f9

@ -2,7 +2,7 @@ export default function loginPageHref(redirectUrl?: string) {
return { return {
pathname: '/login', pathname: '/login',
query: { query: {
redirect: callbackUrl:
typeof window !== 'undefined' typeof window !== 'undefined'
? redirectUrl ?? window.location.href ? redirectUrl ?? window.location.href
: null, : null,

@ -20,6 +20,9 @@ export const authOptions: NextAuthOptions = {
return session; return session;
}, },
}, },
pages: {
signIn: '/login',
},
providers: [ providers: [
GitHubProvider({ GitHubProvider({
clientId: env.GITHUB_CLIENT_ID, clientId: env.GITHUB_CLIENT_ID,

@ -54,9 +54,9 @@ export default function LoginPage({
onClick={() => onClick={() =>
signIn( signIn(
provider.id, provider.id,
router.query.redirect != null router.query.callbackUrl != null
? { ? {
callbackUrl: String(router.query.redirect), callbackUrl: String(router.query.callbackUrl),
} }
: undefined, : undefined,
) )

@ -127,7 +127,7 @@ export default function SettingsPage() {
} }
if (session == null) { if (session == null) {
return null; return <p>You are not signed in</p>;
} }
return ( return (

Loading…
Cancel
Save