first commit

This commit is contained in:
mstfyldz
2026-06-03 04:11:30 +03:00
parent d369c9e258
commit 7b4b3a85af
20 changed files with 3446 additions and 442 deletions
+33
View File
@@ -0,0 +1,33 @@
'use server'
import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'
export async function login(prevState: any, formData: FormData) {
const username = formData.get('username')
const password = formData.get('password')
if (
username === process.env.ADMIN_USERNAME &&
password === process.env.ADMIN_PASSWORD
) {
const cookieStore = await cookies()
cookieStore.set('admin_session', process.env.ADMIN_SECRET || 'secret', {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
path: '/',
maxAge: 60 * 60 * 24 * 7 // 1 week
})
redirect('/admin')
} else {
return { error: 'Geçersiz kullanıcı adı veya şifre' }
}
}
export async function logout() {
const cookieStore = await cookies()
cookieStore.delete('admin_session')
redirect('/admin/login')
}