// ---------------------------------------------------------------------------
-function ensureRegistrationEnabled (req, res, next) {
+function ensureRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) {
const registrationEnabled = CONFIG.SIGNUP.ENABLED
if (registrationEnabled === true) {
return res.status(400).send('User registration is not enabled.')
}
-function createUser (req, res, next) {
+function createUser (req: express.Request, res: express.Response, next: express.NextFunction) {
const user = db.User.build({
username: req.body.username,
password: req.body.password,
role: USER_ROLES.USER
})
- user.save().asCallback(function (err, createdUser) {
+ user.save().asCallback(function (err) {
if (err) return next(err)
return res.type('json').status(204).end()
})
}
-function getUserInformation (req, res, next) {
+function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) {
db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) {
if (err) return next(err)
})
}
-function getUserVideoRating (req, res, next) {
- const videoId = req.params.videoId
- const userId = res.locals.oauth.token.User.id
+function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const videoId = '' + req.params.videoId
+ const userId = +res.locals.oauth.token.User.id
db.UserVideoRate.load(userId, videoId, null, function (err, ratingObj) {
if (err) return next(err)
})
}
-function listUsers (req, res, next) {
+function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) {
db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) {
if (err) return next(err)
})
}
-function removeUser (req, res, next) {
+function removeUser (req: express.Request, res: express.Response, next: express.NextFunction) {
waterfall([
function loadUser (callback) {
db.User.loadById(req.params.id, callback)
})
}
-function updateUser (req, res, next) {
+function updateUser (req: express.Request, res: express.Response, next: express.NextFunction) {
db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) {
if (err) return next(err)
})
}
-function success (req, res, next) {
+function success (req: express.Request, res: express.Response, next: express.NextFunction) {
res.end()
}