mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 06:23:35 -04:00
24 lines
777 B
TypeScript
24 lines
777 B
TypeScript
import { PermissionAreas } from '#shared/helpers.ts';
|
|
import { auditLog } from '~~/server/audit.ts';
|
|
import { getLocale, loadConfig } from '~~/server/data.ts';
|
|
import { approveNounEntry } from '~~/server/nouns.ts';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const locale = getLocale(event);
|
|
checkIsConfigEnabledOr404(await loadConfig(locale), 'nouns');
|
|
|
|
const { user, isGranted } = await useAuthentication(event);
|
|
if (!isGranted(PermissionAreas.Nouns)) {
|
|
throw createError({
|
|
status: 401,
|
|
statusMessage: 'Unauthorised',
|
|
});
|
|
}
|
|
|
|
const id = getRouterParam(event, 'id')!;
|
|
const db = useDatabase();
|
|
await approveNounEntry(db, id, locale);
|
|
|
|
await auditLog({ user }, 'nouns/approved', { id });
|
|
});
|