Files
harheimertc/server/api/auth/passkeys/remove.post.js
Torsten Schulz (local) 0528334eb4
All checks were successful
Code Analysis and Production Deploy / analyze (push) Successful in 5m10s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 2m14s
feat: replace success modal with non-blocking toast notification
feat: add global event listener for mannschaften updates in Navigation component

feat: notify app of mannschaften changes after CSV save and handle visibility changes

refactor: remove unused anlagen page

fix: update CmsMannschaften reference in sportbetrieb page for reactivity

fix: enhance authentication token retrieval in passkey API endpoints

feat: implement refresh session and access token generation for Android clients in passkey login

fix: unify token retrieval method across passkey API endpoints

feat: add MediaTypes utility for JSON content type in Android app

feat: create PasskeyRepository for handling passkey authentication and registration in Android app

feat: add validated text field and rich text components for Android UI

feat: implement newsletter subscription and unsubscription screens in Android app

feat: create public pages including Impressum with dynamic content loading
2026-05-28 08:33:28 +02:00

39 lines
1.3 KiB
JavaScript

import { getUserFromToken, readUsers, writeUsers } from '../../../utils/auth.js'
import { writeAuditLog } from '../../../utils/audit-log.js'
export default defineEventHandler(async (event) => {
const token = getCookie(event, 'auth_token') || getHeader(event, 'authorization')?.replace(/^Bearer\s+/i, '')
const currentUser = token ? await getUserFromToken(token) : null
if (!currentUser) {
throw createError({ statusCode: 401, statusMessage: 'Nicht authentifiziert' })
}
const body = await readBody(event)
const credentialId = String(body?.credentialId || '')
if (!credentialId) {
throw createError({ statusCode: 400, statusMessage: 'credentialId fehlt' })
}
const users = await readUsers()
const idx = users.findIndex(u => u.id === currentUser.id)
if (idx === -1) {
throw createError({ statusCode: 404, statusMessage: 'Benutzer nicht gefunden' })
}
const user = users[idx]
const before = Array.isArray(user.passkeys) ? user.passkeys.length : 0
user.passkeys = (Array.isArray(user.passkeys) ? user.passkeys : []).filter(pk => pk.credentialId !== credentialId)
const after = user.passkeys.length
users[idx] = user
await writeUsers(users)
await writeAuditLog('auth.passkey.removed', { userId: currentUser.id })
return {
success: true,
removed: before !== after
}
})