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) {
|
||||
// This should be handled by middleware, but as a fallback
|
||||
const { redirect } = await import("next/navigation")
|
||||
redirect("/login")
|
||||
redirect("/auth")
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -28,7 +28,7 @@ function SubmitButton() {
|
||||
}
|
||||
|
||||
|
||||
export default function LoginPage() {
|
||||
export default function AuthPage() {
|
||||
const [state, formAction] = useActionState(login, undefined);
|
||||
|
||||
return (
|
||||
+2
-2
@@ -6,7 +6,7 @@ import db from '@/lib/db';
|
||||
|
||||
export const authConfig = {
|
||||
pages: {
|
||||
signIn: '/login',
|
||||
signIn: '/auth',
|
||||
},
|
||||
providers: [
|
||||
// The Credentials provider logic has been moved to src/auth.ts
|
||||
@@ -21,7 +21,7 @@ export const authConfig = {
|
||||
return isLoggedIn;
|
||||
} else if (isLoggedIn) {
|
||||
// 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 true;
|
||||
|
||||
@@ -24,5 +24,5 @@ export async function login(
|
||||
|
||||
|
||||
export async function logout() {
|
||||
await signOut({ redirectTo: '/login' });
|
||||
await signOut({ redirectTo: '/auth' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user