feat(codev): retire Surprise + QR public + mode admin suppr fiches
- 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>
This commit is contained in:
25
server/api/codev/fiches/[id].delete.ts
Normal file
25
server/api/codev/fiches/[id].delete.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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 }
|
||||
})
|
||||
Reference in New Issue
Block a user