Give the dashboard a way to check backgroundImage availability
This commit is contained in:
@@ -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
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user