X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fusers.ts;h=ce15353eff73e6232b5773920ccdeda8d5d0ef01;hb=ba44fa19531186944fef3e9da34f5e91f0c0dedb;hp=ffe5881e5594040e6a5cb9f99fcaf84cee6e59bd;hpb=69818c9394366b954b6ba3bd697bd9d2b09f2a16;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index ffe5881e5..ce15353ef 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts @@ -7,6 +7,7 @@ import { logger, getFormatedObjects } from '../../helpers' import { authenticate, ensureIsAdmin, + ensureUserRegistrationEnabled, usersAddValidator, usersUpdateValidator, usersRemoveValidator, @@ -17,6 +18,7 @@ import { setUsersSort, token } from '../../middlewares' +import { UserVideoRate as FormatedUserVideoRate } from '../../../shared' const usersRouter = express.Router() @@ -47,7 +49,7 @@ usersRouter.post('/', ) usersRouter.post('/register', - ensureRegistrationEnabled, + ensureUserRegistrationEnabled, usersAddValidator, createUser ) @@ -76,16 +78,6 @@ export { // --------------------------------------------------------------------------- -function ensureRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) { - const registrationEnabled = CONFIG.SIGNUP.ENABLED - - if (registrationEnabled === true) { - return next() - } - - return res.status(400).send('User registration is not enabled.') -} - function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { const user = db.User.build({ username: req.body.username, @@ -119,10 +111,11 @@ function getUserVideoRating (req: express.Request, res: express.Response, next: const rating = ratingObj ? ratingObj.type : 'none' - res.json({ + const json: FormatedUserVideoRate = { videoId, rating - }) + } + res.json(json) }) }