diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
commit | dae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch) | |
tree | a5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/users/index.ts | |
parent | e65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff) | |
download | PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip |
Cleanup express locals typings
Diffstat (limited to 'server/controllers/api/users/index.ts')
-rw-r--r-- | server/controllers/api/users/index.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index f7edbddf3..2117bdfeb 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -221,8 +221,8 @@ async function registerUser (req: express.Request, res: express.Response) { | |||
221 | return res.type('json').status(204).end() | 221 | return res.type('json').status(204).end() |
222 | } | 222 | } |
223 | 223 | ||
224 | async function unblockUser (req: express.Request, res: express.Response, next: express.NextFunction) { | 224 | async function unblockUser (req: express.Request, res: express.Response) { |
225 | const user: UserModel = res.locals.user | 225 | const user = res.locals.user |
226 | 226 | ||
227 | await changeUserBlock(res, user, false) | 227 | await changeUserBlock(res, user, false) |
228 | 228 | ||
@@ -230,7 +230,7 @@ async function unblockUser (req: express.Request, res: express.Response, next: e | |||
230 | } | 230 | } |
231 | 231 | ||
232 | async function blockUser (req: express.Request, res: express.Response) { | 232 | async function blockUser (req: express.Request, res: express.Response) { |
233 | const user: UserModel = res.locals.user | 233 | const user = res.locals.user |
234 | const reason = req.body.reason | 234 | const reason = req.body.reason |
235 | 235 | ||
236 | await changeUserBlock(res, user, true, reason) | 236 | await changeUserBlock(res, user, true, reason) |
@@ -239,7 +239,7 @@ async function blockUser (req: express.Request, res: express.Response) { | |||
239 | } | 239 | } |
240 | 240 | ||
241 | function getUser (req: express.Request, res: express.Response) { | 241 | function getUser (req: express.Request, res: express.Response) { |
242 | return res.json((res.locals.user as UserModel).toFormattedJSON()) | 242 | return res.json(res.locals.user.toFormattedJSON()) |
243 | } | 243 | } |
244 | 244 | ||
245 | async function autocompleteUsers (req: express.Request, res: express.Response) { | 245 | async function autocompleteUsers (req: express.Request, res: express.Response) { |
@@ -255,7 +255,7 @@ async function listUsers (req: express.Request, res: express.Response) { | |||
255 | } | 255 | } |
256 | 256 | ||
257 | async function removeUser (req: express.Request, res: express.Response) { | 257 | async function removeUser (req: express.Request, res: express.Response) { |
258 | const user: UserModel = res.locals.user | 258 | const user = res.locals.user |
259 | 259 | ||
260 | await user.destroy() | 260 | await user.destroy() |
261 | 261 | ||
@@ -266,7 +266,7 @@ async function removeUser (req: express.Request, res: express.Response) { | |||
266 | 266 | ||
267 | async function updateUser (req: express.Request, res: express.Response) { | 267 | async function updateUser (req: express.Request, res: express.Response) { |
268 | const body: UserUpdate = req.body | 268 | const body: UserUpdate = req.body |
269 | const userToUpdate = res.locals.user as UserModel | 269 | const userToUpdate = res.locals.user |
270 | const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON()) | 270 | const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON()) |
271 | const roleChanged = body.role !== undefined && body.role !== userToUpdate.role | 271 | const roleChanged = body.role !== undefined && body.role !== userToUpdate.role |
272 | 272 | ||
@@ -289,8 +289,8 @@ async function updateUser (req: express.Request, res: express.Response) { | |||
289 | return res.sendStatus(204) | 289 | return res.sendStatus(204) |
290 | } | 290 | } |
291 | 291 | ||
292 | async function askResetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { | 292 | async function askResetUserPassword (req: express.Request, res: express.Response) { |
293 | const user = res.locals.user as UserModel | 293 | const user = res.locals.user |
294 | 294 | ||
295 | const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) | 295 | const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) |
296 | const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString | 296 | const url = CONFIG.WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString |
@@ -299,8 +299,8 @@ async function askResetUserPassword (req: express.Request, res: express.Response | |||
299 | return res.status(204).end() | 299 | return res.status(204).end() |
300 | } | 300 | } |
301 | 301 | ||
302 | async function resetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { | 302 | async function resetUserPassword (req: express.Request, res: express.Response) { |
303 | const user = res.locals.user as UserModel | 303 | const user = res.locals.user |
304 | user.password = req.body.password | 304 | user.password = req.body.password |
305 | 305 | ||
306 | await user.save() | 306 | await user.save() |
@@ -315,16 +315,16 @@ async function sendVerifyUserEmail (user: UserModel) { | |||
315 | return | 315 | return |
316 | } | 316 | } |
317 | 317 | ||
318 | async function askSendVerifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { | 318 | async function askSendVerifyUserEmail (req: express.Request, res: express.Response) { |
319 | const user = res.locals.user as UserModel | 319 | const user = res.locals.user |
320 | 320 | ||
321 | await sendVerifyUserEmail(user) | 321 | await sendVerifyUserEmail(user) |
322 | 322 | ||
323 | return res.status(204).end() | 323 | return res.status(204).end() |
324 | } | 324 | } |
325 | 325 | ||
326 | async function verifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { | 326 | async function verifyUserEmail (req: express.Request, res: express.Response) { |
327 | const user = res.locals.user as UserModel | 327 | const user = res.locals.user |
328 | user.emailVerified = true | 328 | user.emailVerified = true |
329 | 329 | ||
330 | await user.save() | 330 | await user.save() |
@@ -332,7 +332,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response, nex | |||
332 | return res.status(204).end() | 332 | return res.status(204).end() |
333 | } | 333 | } |
334 | 334 | ||
335 | function success (req: express.Request, res: express.Response, next: express.NextFunction) { | 335 | function success (req: express.Request, res: express.Response) { |
336 | res.end() | 336 | res.end() |
337 | } | 337 | } |
338 | 338 | ||