- Added support for generating Android access tokens and managing refresh sessions in the auth endpoints. - Implemented new tests for login, logout, and refresh functionalities specific to Android clients. - Enhanced password reset logging with normalization and masking of email addresses. - Created a new diagnostics endpoint for password reset attempts, including filtering and summarizing logs. - Introduced a new utility for managing password reset logs with retention policies. - Added tests for password reset log utilities to ensure proper functionality and privacy compliance. - Updated WebAuthn configuration tests to validate origin handling for production and allowed origins.
31 lines
774 B
JavaScript
31 lines
774 B
JavaScript
import { deleteSession, revokeRefreshSession } from '../../utils/auth.js'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
const token = getCookie(event, 'auth_token') || getHeader(event, 'authorization')?.replace(/^Bearer\s+/i, '')
|
|
const body = await readBody(event)
|
|
const refreshToken = body?.refreshToken
|
|
|
|
if (token) {
|
|
await deleteSession(token)
|
|
}
|
|
if (refreshToken) {
|
|
await revokeRefreshSession(refreshToken)
|
|
}
|
|
|
|
// 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'
|
|
})
|
|
}
|
|
})
|