|
@ -64,6 +64,12 @@ class UserController extends SiteController { |
|
|
this.postProfilePhoto.bind(this), |
|
|
this.postProfilePhoto.bind(this), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
router.post('/:userId/header-image', |
|
|
|
|
|
limiterService.create(limiterService.config.user.postHeaderImage), |
|
|
|
|
|
upload.single('imageFile'), |
|
|
|
|
|
this.postHeaderImage.bind(this), |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
router.post('/:userId/settings', |
|
|
router.post('/:userId/settings', |
|
|
limiterService.create(limiterService.config.user.postUpdateSettings), |
|
|
limiterService.create(limiterService.config.user.postUpdateSettings), |
|
|
upload.none(), |
|
|
upload.none(), |
|
@ -96,6 +102,13 @@ class UserController extends SiteController { |
|
|
checkProfileOwner, |
|
|
checkProfileOwner, |
|
|
this.deleteProfilePhoto.bind(this), |
|
|
this.deleteProfilePhoto.bind(this), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
router.delete('/:userId/header-image', |
|
|
|
|
|
limiterService.create(limiterService.config.user.deleteHeaderImage), |
|
|
|
|
|
authRequired, |
|
|
|
|
|
checkProfileOwner, |
|
|
|
|
|
this.deleteHeaderImage.bind(this), |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async populateUser (req, res, next, userId) { |
|
|
async populateUser (req, res, next, userId) { |
|
@ -153,10 +166,7 @@ class UserController extends SiteController { |
|
|
const { user: userService } = this.dtp.services; |
|
|
const { user: userService } = this.dtp.services; |
|
|
try { |
|
|
try { |
|
|
const displayList = this.createDisplayList('profile-photo'); |
|
|
const displayList = this.createDisplayList('profile-photo'); |
|
|
|
|
|
|
|
|
this.log.debug('received profile photo', { file: req.file }); |
|
|
|
|
|
await userService.updatePhoto(req.user, req.file); |
|
|
await userService.updatePhoto(req.user, req.file); |
|
|
|
|
|
|
|
|
displayList.showNotification( |
|
|
displayList.showNotification( |
|
|
'Profile photo updated successfully.', |
|
|
'Profile photo updated successfully.', |
|
|
'success', |
|
|
'success', |
|
@ -173,6 +183,27 @@ class UserController extends SiteController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async postHeaderImage (req, res) { |
|
|
|
|
|
const { user: userService } = this.dtp.services; |
|
|
|
|
|
try { |
|
|
|
|
|
const displayList = this.createDisplayList('header-image'); |
|
|
|
|
|
await userService.updateHeaderImage(req.user, req.file); |
|
|
|
|
|
displayList.showNotification( |
|
|
|
|
|
'Header image updated successfully.', |
|
|
|
|
|
'success', |
|
|
|
|
|
'bottom-center', |
|
|
|
|
|
2000, |
|
|
|
|
|
); |
|
|
|
|
|
res.status(200).json({ success: true, displayList }); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
this.log.error('failed to update header image', { error }); |
|
|
|
|
|
return res.status(error.statusCode || 500).json({ |
|
|
|
|
|
success: false, |
|
|
|
|
|
message: error.message, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async postUpdateSettings (req, res) { |
|
|
async postUpdateSettings (req, res) { |
|
|
const { user: userService } = this.dtp.services; |
|
|
const { user: userService } = this.dtp.services; |
|
|
try { |
|
|
try { |
|
@ -219,9 +250,7 @@ class UserController extends SiteController { |
|
|
const { user: userService } = this.dtp.services; |
|
|
const { user: userService } = this.dtp.services; |
|
|
try { |
|
|
try { |
|
|
const displayList = this.createDisplayList('app-settings'); |
|
|
const displayList = this.createDisplayList('app-settings'); |
|
|
|
|
|
|
|
|
await userService.removePhoto(req.user); |
|
|
await userService.removePhoto(req.user); |
|
|
|
|
|
|
|
|
displayList.showNotification( |
|
|
displayList.showNotification( |
|
|
'Profile photo removed successfully.', |
|
|
'Profile photo removed successfully.', |
|
|
'success', |
|
|
'success', |
|
@ -237,6 +266,27 @@ class UserController extends SiteController { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async deleteHeaderImage (req, res) { |
|
|
|
|
|
const { user: userService } = this.dtp.services; |
|
|
|
|
|
try { |
|
|
|
|
|
const displayList = this.createDisplayList('remove-header-image'); |
|
|
|
|
|
await userService.removeHeaderImage(req.user); |
|
|
|
|
|
displayList.showNotification( |
|
|
|
|
|
'Header image removed successfully.', |
|
|
|
|
|
'success', |
|
|
|
|
|
'bottom-center', |
|
|
|
|
|
2000, |
|
|
|
|
|
); |
|
|
|
|
|
res.status(200).json({ success: true, displayList }); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
this.log.error('failed to remove header image', { error }); |
|
|
|
|
|
return res.status(error.statusCode || 500).json({ |
|
|
|
|
|
success: false, |
|
|
|
|
|
message: error.message, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|