|
|
|
@ -33,12 +33,12 @@ class UserController extends SiteController {
|
|
|
|
|
const otpSetup = otpAuthService.middleware('Account', {
|
|
|
|
|
adminRequired: false,
|
|
|
|
|
otpRequired: true,
|
|
|
|
|
otpRedirectURL: async (req) => { return `/user/${req.user._id}`; },
|
|
|
|
|
otpRedirectURL: async (req) => { return `/user/${req.user.username}`; },
|
|
|
|
|
});
|
|
|
|
|
const otpMiddleware = otpAuthService.middleware('Account', {
|
|
|
|
|
adminRequired: false,
|
|
|
|
|
otpRequired: false,
|
|
|
|
|
otpRedirectURL: async (req) => { return `/user/${req.user._id}`; },
|
|
|
|
|
otpRedirectURL: async (req) => { return `/user/${req.user.username}`; },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
router.use(
|
|
|
|
@ -61,8 +61,8 @@ class UserController extends SiteController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
router.param('username', this.populateUsername.bind(this));
|
|
|
|
|
router.param('userId', this.populateUser.bind(this));
|
|
|
|
|
router.param('coreUserId', this.populateCoreUser.bind(this));
|
|
|
|
|
router.param('userId', this.populateUserId.bind(this));
|
|
|
|
|
router.param('coreUserId', this.populateCoreUserId.bind(this));
|
|
|
|
|
|
|
|
|
|
router.post(
|
|
|
|
|
'/core/:coreUserId/settings',
|
|
|
|
@ -162,7 +162,7 @@ class UserController extends SiteController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async populateUser (req, res, next, userId) {
|
|
|
|
|
async populateUserId (req, res, next, userId) {
|
|
|
|
|
const { user: userService } = this.dtp.services;
|
|
|
|
|
try {
|
|
|
|
|
userId = mongoose.Types.ObjectId(userId);
|
|
|
|
@ -178,7 +178,7 @@ class UserController extends SiteController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async populateCoreUser (req, res, next, coreUserId) {
|
|
|
|
|
async populateCoreUserId (req, res, next, coreUserId) {
|
|
|
|
|
const { coreNode: coreNodeService } = this.dtp.services;
|
|
|
|
|
try {
|
|
|
|
|
coreUserId = mongoose.Types.ObjectId(coreUserId);
|
|
|
|
@ -218,7 +218,7 @@ class UserController extends SiteController {
|
|
|
|
|
if (error) {
|
|
|
|
|
return next(error);
|
|
|
|
|
}
|
|
|
|
|
res.redirect(`/user/${res.locals.user._id}`);
|
|
|
|
|
res.redirect(`/user/${res.locals.user.username}`);
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
this.log.error('failed to create new user', { error });
|
|
|
|
|