From 74cf50939728ebf09615ba5702693ce82482e2d5 Mon Sep 17 00:00:00 2001 From: DerTyp7 Date: Mon, 6 Oct 2025 19:51:41 +0200 Subject: [PATCH] Do not use callback url --- src/lib/actions.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/actions.ts b/src/lib/actions.ts index 19e4376..ef92bde 100644 --- a/src/lib/actions.ts +++ b/src/lib/actions.ts @@ -3,11 +3,20 @@ import { signIn } from '@/auth'; import { AuthError } from 'next-auth'; import { cookies } from 'next/headers'; +import { redirect } from 'next/navigation'; export async function authenticate(_prevState: string | undefined, formData: FormData): Promise { try { - await signIn('credentials', formData); - return 'success'; + const result = await signIn('credentials', { + redirect: false, + token: formData.get('token'), + }); + + if (result?.error) { + return 'Invalid token'; + } + + redirect('/admin'); } catch (error) { if (error instanceof AuthError) { switch (error.type) {