create a login page /auth
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -37,7 +37,7 @@ async function AdminLayout({
|
|||||||
if (!session) {
|
if (!session) {
|
||||||
// This should be handled by middleware, but as a fallback
|
// This should be handled by middleware, but as a fallback
|
||||||
const { redirect } = await import("next/navigation")
|
const { redirect } = await import("next/navigation")
|
||||||
redirect("/login")
|
redirect("/auth")
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function SubmitButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function AuthPage() {
|
||||||
const [state, formAction] = useActionState(login, undefined);
|
const [state, formAction] = useActionState(login, undefined);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
+2
-2
@@ -6,7 +6,7 @@ import db from '@/lib/db';
|
|||||||
|
|
||||||
export const authConfig = {
|
export const authConfig = {
|
||||||
pages: {
|
pages: {
|
||||||
signIn: '/login',
|
signIn: '/auth',
|
||||||
},
|
},
|
||||||
providers: [
|
providers: [
|
||||||
// The Credentials provider logic has been moved to src/auth.ts
|
// The Credentials provider logic has been moved to src/auth.ts
|
||||||
@@ -21,7 +21,7 @@ export const authConfig = {
|
|||||||
return isLoggedIn;
|
return isLoggedIn;
|
||||||
} else if (isLoggedIn) {
|
} else if (isLoggedIn) {
|
||||||
// Redirect logged-in users from the login page to the admin dashboard
|
// Redirect logged-in users from the login page to the admin dashboard
|
||||||
if (nextUrl.pathname === '/login') {
|
if (nextUrl.pathname === '/auth') {
|
||||||
return Response.redirect(new URL('/admin', nextUrl));
|
return Response.redirect(new URL('/admin', nextUrl));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,5 +24,5 @@ export async function login(
|
|||||||
|
|
||||||
|
|
||||||
export async function logout() {
|
export async function logout() {
|
||||||
await signOut({ redirectTo: '/login' });
|
await signOut({ redirectTo: '/auth' });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user