Return user id as minimum data in /users/me

This commit is contained in:
rijkvanzanten
2020-10-19 11:18:58 -04:00
parent fa1674c41b
commit 09d8f670f5

View File

@@ -58,11 +58,21 @@ router.get(
if (!req.accountability?.user) {
throw new InvalidCredentialsException();
}
const service = new UsersService({ accountability: req.accountability });
const item = await service.readByKey(req.accountability.user, req.sanitizedQuery);
try {
const item = await service.readByKey(req.accountability.user, req.sanitizedQuery);
res.locals.payload = { data: item || null };
} catch (error) {
if (error instanceof ForbiddenException) {
res.locals.payload = { data: { id: req.accountability.user } };
return next();
}
throw error;
}
res.locals.payload = { data: item || null };
return next();
}),
respond