+ const user = res.locals.oauth.token.User
+
+ if (req.body.password || req.body.email) {
+ if (user.pluginAuth !== null) {
+ return res.fail({ message: 'You cannot update your email or password that is associated with an external auth system.' })
+ }
+
+ if (!req.body.currentPassword) {
+ return res.fail({ message: 'currentPassword parameter is missing.' })
+ }
+
+ if (await user.isPasswordMatch(req.body.currentPassword) !== true) {
+ return res.fail({
+ status: HttpStatusCode.UNAUTHORIZED_401,
+ message: 'currentPassword is invalid.'
+ })
+ }
+ }
+
+ if (areValidationErrors(req, res)) return
+
+ return next()
+ }
+]
+
+const usersGetValidator = [
+ param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
+ query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking usersGet parameters', { parameters: req.params })
+
+ if (areValidationErrors(req, res)) return
+ if (!await checkUserIdExist(req.params.id, res, req.query.withStats)) return
+
+ return next()
+ }
+]
+
+const usersVideoRatingValidator = [
+ isValidVideoIdParam('videoId'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking usersVideoRating parameters', { parameters: req.params })
+