Give the dashboard a way to check backgroundImage availability

This commit is contained in:
Johannes Zellner
2022-05-17 15:25:44 +02:00
parent f3c66056b5
commit aa1e8dc930
+6 -1
View File
@@ -39,10 +39,14 @@ async function authorize(req, res, next) {
async function get(req, res, next) {
assert.strictEqual(typeof req.user, 'object');
const [error, avatarUrl] = await safe(users.getAvatarUrl(req.user));
let [error, avatarUrl] = await safe(users.getAvatarUrl(req.user));
if (error) return next(BoxError.toHttpError(error));
if (!avatarUrl) return next(new HttpError(404, 'User not found'));
let backgroundImage;
[error, backgroundImage] = await safe(users.getBackgroundImage(req.user.id));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {
id: req.user.id,
username: req.user.username,
@@ -52,6 +56,7 @@ async function get(req, res, next) {
twoFactorAuthenticationEnabled: req.user.twoFactorAuthenticationEnabled,
role: req.user.role,
source: req.user.source,
hasBackgroundImage: !!backgroundImage,
avatarUrl
}));
}