mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-02-10 22:15:06 +08:00
[portal][feat] configure Next Auth's sign in route to point to custom login page
This commit is contained in:
@@ -2,7 +2,7 @@ export default function loginPageHref(redirectUrl?: string) {
|
||||
return {
|
||||
pathname: '/login',
|
||||
query: {
|
||||
redirect:
|
||||
callbackUrl:
|
||||
typeof window !== 'undefined'
|
||||
? redirectUrl ?? window.location.href
|
||||
: null,
|
||||
|
||||
@@ -20,6 +20,9 @@ export const authOptions: NextAuthOptions = {
|
||||
return session;
|
||||
},
|
||||
},
|
||||
pages: {
|
||||
signIn: '/login',
|
||||
},
|
||||
providers: [
|
||||
GitHubProvider({
|
||||
clientId: env.GITHUB_CLIENT_ID,
|
||||
|
||||
@@ -54,9 +54,9 @@ export default function LoginPage({
|
||||
onClick={() =>
|
||||
signIn(
|
||||
provider.id,
|
||||
router.query.redirect != null
|
||||
router.query.callbackUrl != null
|
||||
? {
|
||||
callbackUrl: String(router.query.redirect),
|
||||
callbackUrl: String(router.query.callbackUrl),
|
||||
}
|
||||
: undefined,
|
||||
)
|
||||
|
||||
@@ -127,7 +127,7 @@ export default function SettingsPage() {
|
||||
}
|
||||
|
||||
if (session == null) {
|
||||
return null;
|
||||
return <p>You are not signed in</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user