update
This commit is contained in:
@@ -120,6 +120,29 @@ class AtemschutzController {
|
||||
}
|
||||
}
|
||||
|
||||
async getByUserId(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const { userId } = req.params as Record<string, string>;
|
||||
if (!isValidUUID(userId)) {
|
||||
res.status(400).json({ success: false, message: 'Ungültige Benutzer-ID' });
|
||||
return;
|
||||
}
|
||||
const callerId = getUserId(req);
|
||||
const callerGroups: string[] = (req.user as any)?.groups ?? [];
|
||||
const privileged = ['dashboard_admin', 'dashboard_kommando', 'dashboard_atemschutz', 'dashboard_moderator'];
|
||||
const isPrivileged = callerGroups.some((g) => privileged.includes(g));
|
||||
if (userId !== callerId && !isPrivileged) {
|
||||
res.status(403).json({ success: false, message: 'Keine Berechtigung' });
|
||||
return;
|
||||
}
|
||||
const record = await atemschutzService.getByUserId(userId);
|
||||
res.status(200).json({ success: true, data: record ?? null });
|
||||
} catch (error) {
|
||||
logger.error('Atemschutz getByUserId error', { error, userId: req.params.userId });
|
||||
res.status(500).json({ success: false, message: 'Atemschutzstatus konnte nicht geladen werden' });
|
||||
}
|
||||
}
|
||||
|
||||
async getMyStatus(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const userId = getUserId(req);
|
||||
|
||||
Reference in New Issue
Block a user