diff options
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r-- | server/controllers/api/users.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 44c5ec13c..ffe5881e5 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts | |||
@@ -76,7 +76,7 @@ export { | |||
76 | 76 | ||
77 | // --------------------------------------------------------------------------- | 77 | // --------------------------------------------------------------------------- |
78 | 78 | ||
79 | function ensureRegistrationEnabled (req, res, next) { | 79 | function ensureRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) { |
80 | const registrationEnabled = CONFIG.SIGNUP.ENABLED | 80 | const registrationEnabled = CONFIG.SIGNUP.ENABLED |
81 | 81 | ||
82 | if (registrationEnabled === true) { | 82 | if (registrationEnabled === true) { |
@@ -86,7 +86,7 @@ function ensureRegistrationEnabled (req, res, next) { | |||
86 | return res.status(400).send('User registration is not enabled.') | 86 | return res.status(400).send('User registration is not enabled.') |
87 | } | 87 | } |
88 | 88 | ||
89 | function createUser (req, res, next) { | 89 | function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { |
90 | const user = db.User.build({ | 90 | const user = db.User.build({ |
91 | username: req.body.username, | 91 | username: req.body.username, |
92 | password: req.body.password, | 92 | password: req.body.password, |
@@ -95,14 +95,14 @@ function createUser (req, res, next) { | |||
95 | role: USER_ROLES.USER | 95 | role: USER_ROLES.USER |
96 | }) | 96 | }) |
97 | 97 | ||
98 | user.save().asCallback(function (err, createdUser) { | 98 | user.save().asCallback(function (err) { |
99 | if (err) return next(err) | 99 | if (err) return next(err) |
100 | 100 | ||
101 | return res.type('json').status(204).end() | 101 | return res.type('json').status(204).end() |
102 | }) | 102 | }) |
103 | } | 103 | } |
104 | 104 | ||
105 | function getUserInformation (req, res, next) { | 105 | function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) { |
106 | db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { | 106 | db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { |
107 | if (err) return next(err) | 107 | if (err) return next(err) |
108 | 108 | ||
@@ -110,9 +110,9 @@ function getUserInformation (req, res, next) { | |||
110 | }) | 110 | }) |
111 | } | 111 | } |
112 | 112 | ||
113 | function getUserVideoRating (req, res, next) { | 113 | function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) { |
114 | const videoId = req.params.videoId | 114 | const videoId = '' + req.params.videoId |
115 | const userId = res.locals.oauth.token.User.id | 115 | const userId = +res.locals.oauth.token.User.id |
116 | 116 | ||
117 | db.UserVideoRate.load(userId, videoId, null, function (err, ratingObj) { | 117 | db.UserVideoRate.load(userId, videoId, null, function (err, ratingObj) { |
118 | if (err) return next(err) | 118 | if (err) return next(err) |
@@ -126,7 +126,7 @@ function getUserVideoRating (req, res, next) { | |||
126 | }) | 126 | }) |
127 | } | 127 | } |
128 | 128 | ||
129 | function listUsers (req, res, next) { | 129 | function listUsers (req: express.Request, res: express.Response, next: express.NextFunction) { |
130 | db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) { | 130 | db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) { |
131 | if (err) return next(err) | 131 | if (err) return next(err) |
132 | 132 | ||
@@ -134,7 +134,7 @@ function listUsers (req, res, next) { | |||
134 | }) | 134 | }) |
135 | } | 135 | } |
136 | 136 | ||
137 | function removeUser (req, res, next) { | 137 | function removeUser (req: express.Request, res: express.Response, next: express.NextFunction) { |
138 | waterfall([ | 138 | waterfall([ |
139 | function loadUser (callback) { | 139 | function loadUser (callback) { |
140 | db.User.loadById(req.params.id, callback) | 140 | db.User.loadById(req.params.id, callback) |
@@ -153,7 +153,7 @@ function removeUser (req, res, next) { | |||
153 | }) | 153 | }) |
154 | } | 154 | } |
155 | 155 | ||
156 | function updateUser (req, res, next) { | 156 | function updateUser (req: express.Request, res: express.Response, next: express.NextFunction) { |
157 | db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { | 157 | db.User.loadByUsername(res.locals.oauth.token.user.username, function (err, user) { |
158 | if (err) return next(err) | 158 | if (err) return next(err) |
159 | 159 | ||
@@ -168,6 +168,6 @@ function updateUser (req, res, next) { | |||
168 | }) | 168 | }) |
169 | } | 169 | } |
170 | 170 | ||
171 | function success (req, res, next) { | 171 | function success (req: express.Request, res: express.Response, next: express.NextFunction) { |
172 | res.end() | 172 | res.end() |
173 | } | 173 | } |