Starting over

This commit is contained in:
2025-10-01 22:00:32 -04:00
parent 6d0f99507a
commit 793f395795
29 changed files with 0 additions and 1542 deletions

View File

@@ -1,37 +0,0 @@
import { authenticateUser, createJWT } from '~/server/utils/auth'
export default defineEventHandler(async (event) => {
const body = await readBody(event)
const { username, password } = body
if (!username || !password) {
throw createError({
statusCode: 400,
statusMessage: 'Username and password are required'
})
}
const user = await authenticateUser(username, password)
if (!user) {
throw createError({
statusCode: 401,
statusMessage: 'Invalid credentials'
})
}
const token = await createJWT(user)
setCookie(event, 'auth_token', token, {
httpOnly: false,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
maxAge: 7 * 24 * 60 * 60 // 7 days
})
return {
user: {
id: user.id,
username: user.username
}
}
})