User generatable API tokens (#2621)

This commit is contained in:
Kalle
2025-11-09 11:07:20 +02:00
committed by GitHub
parent 47e9262d40
commit ff4402d9aa
38 changed files with 1045 additions and 20 deletions

View File

@@ -159,6 +159,14 @@ export const action = async ({ request }: ActionFunctionArgs) => {
message = "Friend code updated";
break;
}
case "API_ACCESS": {
requireRole(user, "ADMIN");
await AdminRepository.makeApiAccesserByUserId(data.user);
message = "API access granted";
break;
}
default: {
assertUnreachable(data);
}
@@ -217,4 +225,8 @@ export const adminActionSchema = z.union([
friendCode,
user: z.preprocess(actualNumber, z.number().positive()),
}),
z.object({
_action: _action("API_ACCESS"),
user: z.preprocess(actualNumber, z.number().positive()),
}),
]);