Add authentication system with login, password reset, and member area
This commit is contained in:
26
server/api/auth/logout.post.js
Normal file
26
server/api/auth/logout.post.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { deleteSession } from '../../utils/auth.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const token = getCookie(event, 'auth_token')
|
||||
|
||||
if (token) {
|
||||
await deleteSession(token)
|
||||
}
|
||||
|
||||
// Delete cookie
|
||||
deleteCookie(event, 'auth_token')
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'Erfolgreich abgemeldet'
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Logout-Fehler:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: 'Abmeldung fehlgeschlagen'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user