|
|
@ -22,37 +22,36 @@ class UserController extends SiteController {
|
|
|
|
return next();
|
|
|
|
return next();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
router.param('userId', this.populateUserId.bind(this));
|
|
|
|
router.param('localUserId', this.populateLocalUserId.bind(this));
|
|
|
|
|
|
|
|
router.post('/local/:localUserId', this.postUpdateLocalUser.bind(this));
|
|
|
|
|
|
|
|
router.get('/local/:localUserId', this.getLocalUserView.bind(this));
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/:userId', this.postUpdateUser.bind(this));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/:userId', this.getUserView.bind(this));
|
|
|
|
|
|
|
|
router.get('/', this.getHomeView.bind(this));
|
|
|
|
router.get('/', this.getHomeView.bind(this));
|
|
|
|
|
|
|
|
|
|
|
|
return router;
|
|
|
|
return router;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async populateUserId (req, res, next, userId) {
|
|
|
|
async populateLocalUserId (req, res, next, localUserId) {
|
|
|
|
const { user: userService } = this.dtp.services;
|
|
|
|
const { user: userService } = this.dtp.services;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
res.locals.userAccount = await userService.getUserAccount(userId);
|
|
|
|
res.locals.userAccount = await userService.getLocalUserAccount(localUserId);
|
|
|
|
return next();
|
|
|
|
return next();
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
return next(error);
|
|
|
|
return next(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async postUpdateUser (req, res, next) {
|
|
|
|
async postUpdateLocalUser (req, res, next) {
|
|
|
|
const { user: userService } = this.dtp.services;
|
|
|
|
const { user: userService } = this.dtp.services;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await userService.updateForAdmin(res.locals.userAccount, req.body);
|
|
|
|
await userService.updateLocalForAdmin(res.locals.userAccount, req.body);
|
|
|
|
res.redirect('/admin/user');
|
|
|
|
res.redirect('/admin/user');
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
return next(error);
|
|
|
|
return next(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async getUserView (req, res, next) {
|
|
|
|
async getLocalUserView (req, res, next) {
|
|
|
|
const { comment: commentService } = this.dtp.services;
|
|
|
|
const { comment: commentService } = this.dtp.services;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
res.locals.pagination = this.getPaginationParameters(req, 20);
|
|
|
|
res.locals.pagination = this.getPaginationParameters(req, 20);
|
|
|
|