mirror of
https://github.com/DerTyp7/f1r3wave-website.git
synced 2025-10-29 13:02:09 +01:00
Do not use callback url
This commit is contained in:
@@ -3,11 +3,20 @@
|
|||||||
import { signIn } from '@/auth';
|
import { signIn } from '@/auth';
|
||||||
import { AuthError } from 'next-auth';
|
import { AuthError } from 'next-auth';
|
||||||
import { cookies } from 'next/headers';
|
import { cookies } from 'next/headers';
|
||||||
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
export async function authenticate(_prevState: string | undefined, formData: FormData): Promise<string> {
|
export async function authenticate(_prevState: string | undefined, formData: FormData): Promise<string> {
|
||||||
try {
|
try {
|
||||||
await signIn('credentials', formData);
|
const result = await signIn('credentials', {
|
||||||
return 'success';
|
redirect: false,
|
||||||
|
token: formData.get('token'),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result?.error) {
|
||||||
|
return 'Invalid token';
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect('/admin');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof AuthError) {
|
if (error instanceof AuthError) {
|
||||||
switch (error.type) {
|
switch (error.type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user