|
@ -63,6 +63,14 @@ class UserController extends SiteController { |
|
|
router.param('userId', this.populateUser.bind(this)); |
|
|
router.param('userId', this.populateUser.bind(this)); |
|
|
router.param('coreUserId', this.populateCoreUser.bind(this)); |
|
|
router.param('coreUserId', this.populateCoreUser.bind(this)); |
|
|
|
|
|
|
|
|
|
|
|
router.post( |
|
|
|
|
|
'/core/:userId/settings', |
|
|
|
|
|
limiterService.create(limiterService.config.user.postUpdateCoreSettings), |
|
|
|
|
|
checkProfileOwner, |
|
|
|
|
|
upload.none(), |
|
|
|
|
|
this.postUpdateCoreSettings.bind(this), |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
router.post( |
|
|
router.post( |
|
|
'/:userId/profile-photo', |
|
|
'/:userId/profile-photo', |
|
|
limiterService.create(limiterService.config.user.postProfilePhoto), |
|
|
limiterService.create(limiterService.config.user.postProfilePhoto), |
|
@ -91,7 +99,7 @@ class UserController extends SiteController { |
|
|
authRequired, |
|
|
authRequired, |
|
|
otpMiddleware, |
|
|
otpMiddleware, |
|
|
checkProfileOwner, |
|
|
checkProfileOwner, |
|
|
this.getUserSettingsView.bind(this), |
|
|
this.getCoreUserSettingsView.bind(this), |
|
|
); |
|
|
); |
|
|
router.get( |
|
|
router.get( |
|
|
'/core/:coreUserId', |
|
|
'/core/:coreUserId', |
|
@ -250,6 +258,24 @@ class UserController extends SiteController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async postUpdateCoreSettings (req, res) { |
|
|
|
|
|
const { coreNode: coreNodeService } = this.dtp.services; |
|
|
|
|
|
try { |
|
|
|
|
|
const displayList = this.createDisplayList('app-settings'); |
|
|
|
|
|
|
|
|
|
|
|
await coreNodeService.updateUserSettings(req.user, req.body); |
|
|
|
|
|
|
|
|
|
|
|
displayList.reload(); |
|
|
|
|
|
res.status(200).json({ success: true, displayList }); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
this.log.error('failed to update CoreUser settings', { 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 { |
|
@ -287,6 +313,18 @@ class UserController extends SiteController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async getCoreUserSettingsView (req, res, next) { |
|
|
|
|
|
const { otpAuth: otpAuthService } = this.dtp.services; |
|
|
|
|
|
try { |
|
|
|
|
|
res.locals.hasOtpAccount = await otpAuthService.isUserProtected(req.user, 'Account'); |
|
|
|
|
|
res.locals.startTab = req.query.st || 'watch'; |
|
|
|
|
|
res.render('user/settings-core'); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
this.log.error('failed to render CoreUser settings view', { error }); |
|
|
|
|
|
return next(error); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async getUserSettingsView (req, res, next) { |
|
|
async getUserSettingsView (req, res, next) { |
|
|
const { otpAuth: otpAuthService } = this.dtp.services; |
|
|
const { otpAuth: otpAuthService } = this.dtp.services; |
|
|
try { |
|
|
try { |
|
@ -294,7 +332,7 @@ class UserController extends SiteController { |
|
|
res.locals.startTab = req.query.st || 'watch'; |
|
|
res.locals.startTab = req.query.st || 'watch'; |
|
|
res.render('user/settings'); |
|
|
res.render('user/settings'); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
this.log.error('failed to produce user settings view', { error }); |
|
|
this.log.error('failed to render user settings view', { error }); |
|
|
return next(error); |
|
|
return next(error); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|