- carto.vue : retire bouton Surprise (Alliance seul reste), ajoute isAdmin + deleteFiche + colonne supprimer annuaire
- middleware : /codev/qr exempté d'authentification
- auth.post.ts : détecte mdp admin → pose cookie codev_admin
- DELETE /api/codev/fiches/[id] : vérifie cookie admin avant suppression NocoDB
- GET /api/codev/me : retourne { admin, session }
- nuxt.config.ts : codevAdminPassword ajouté
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
832 B
TypeScript
26 lines
832 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
// Vérif cookie admin
|
|
const adminCookie = getCookie(event, 'codev_admin')
|
|
if (adminCookie !== 'ok') {
|
|
throw createError({ statusCode: 403, statusMessage: 'Accès refusé' })
|
|
}
|
|
|
|
const config = useRuntimeConfig()
|
|
const tableId = config.codevTableId
|
|
const id = getRouterParam(event, 'id')
|
|
|
|
if (!tableId || !id) {
|
|
throw createError({ statusCode: 400, message: 'Parametre manquant' })
|
|
}
|
|
|
|
await $fetch(`${config.nocodbUrl}/api/v2/tables/${tableId}/records`, {
|
|
method: 'DELETE',
|
|
headers: { 'xc-token': config.nocodbToken, 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ Id: Number(id) }),
|
|
}).catch(() => {
|
|
throw createError({ statusCode: 502, statusMessage: 'Erreur suppression' })
|
|
})
|
|
|
|
return { status: 200, ok: true }
|
|
})
|