X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fusers.ts;h=548d5df4df334aa83825e3bd31cf8bab05f31ac7;hb=8ee37c5f38b0f9b7e97239197d5590109c163250;hp=c93895f2f15ebdf82321d08b9b20d7ee30bcc509;hpb=2d53be0267acc49cda46707b885096193a1f4e9c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index c93895f2f..548d5df4d 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -1,8 +1,14 @@ -import * as Bluebird from 'bluebird' import * as express from 'express' import { body, param, query } from 'express-validator' import { omit } from 'lodash' +import { Hooks } from '@server/lib/plugins/hooks' +import { MUserDefault } from '@server/types/models' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { UserRole } from '../../../shared/models/users' +import { UserRegister } from '../../../shared/models/users/user-register.model' +import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' import { isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' +import { isThemeNameValid } from '../../helpers/custom-validators/plugins' import { isNoInstanceConfigWarningModal, isNoWelcomeModal, @@ -22,22 +28,15 @@ import { isUserVideoQuotaValid, isUserVideosHistoryEnabledValid } from '../../helpers/custom-validators/users' +import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' import { logger } from '../../helpers/logger' +import { doesVideoExist } from '../../helpers/middlewares' import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' +import { isThemeRegistered } from '../../lib/plugins/theme-utils' import { Redis } from '../../lib/redis' -import { UserModel } from '../../models/account/user' +import { UserModel } from '../../models/user/user' +import { ActorModel } from '../../models/actor/actor' import { areValidationErrors } from './utils' -import { ActorModel } from '../../models/activitypub/actor' -import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' -import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' -import { UserRegister } from '../../../shared/models/users/user-register.model' -import { isThemeNameValid } from '../../helpers/custom-validators/plugins' -import { isThemeRegistered } from '../../lib/plugins/theme-utils' -import { doesVideoExist } from '../../helpers/middlewares' -import { UserRole } from '../../../shared/models/users' -import { MUserDefault } from '@server/types/models' -import { Hooks } from '@server/lib/plugins/hooks' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const usersListValidator = [ query('blocked') @@ -197,11 +196,13 @@ const deleteMeValidator = [ const usersUpdateValidator = [ param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), body('email').optional().isEmail().withMessage('Should have a valid email attribute'), body('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'), body('videoQuota').optional().custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'), body('videoQuotaDaily').optional().custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), + body('pluginAuth').optional(), body('role') .optional() .customSanitizer(toIntOrNull) @@ -529,7 +530,7 @@ async function checkUserNameOrEmailDoesNotAlreadyExist (username: string, email: return true } -async function checkUserExist (finder: () => Bluebird, res: express.Response, abortResponse = true) { +async function checkUserExist (finder: () => Promise, res: express.Response, abortResponse = true) { const user = await finder() if (!user) {