From dae86118ed5d4026d04acb9d0e36829b9ad8eb4e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Mar 2019 10:35:15 +0100 Subject: Cleanup express locals typings --- server/controllers/api/users/index.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'server/controllers/api/users/index.ts') 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) { return res.type('json').status(204).end() } -async function unblockUser (req: express.Request, res: express.Response, next: express.NextFunction) { - const user: UserModel = res.locals.user +async function unblockUser (req: express.Request, res: express.Response) { + const user = res.locals.user await changeUserBlock(res, user, false) @@ -230,7 +230,7 @@ async function unblockUser (req: express.Request, res: express.Response, next: e } async function blockUser (req: express.Request, res: express.Response) { - const user: UserModel = res.locals.user + const user = res.locals.user const reason = req.body.reason await changeUserBlock(res, user, true, reason) @@ -239,7 +239,7 @@ async function blockUser (req: express.Request, res: express.Response) { } function getUser (req: express.Request, res: express.Response) { - return res.json((res.locals.user as UserModel).toFormattedJSON()) + return res.json(res.locals.user.toFormattedJSON()) } async function autocompleteUsers (req: express.Request, res: express.Response) { @@ -255,7 +255,7 @@ async function listUsers (req: express.Request, res: express.Response) { } async function removeUser (req: express.Request, res: express.Response) { - const user: UserModel = res.locals.user + const user = res.locals.user await user.destroy() @@ -266,7 +266,7 @@ async function removeUser (req: express.Request, res: express.Response) { async function updateUser (req: express.Request, res: express.Response) { const body: UserUpdate = req.body - const userToUpdate = res.locals.user as UserModel + const userToUpdate = res.locals.user const oldUserAuditView = new UserAuditView(userToUpdate.toFormattedJSON()) const roleChanged = body.role !== undefined && body.role !== userToUpdate.role @@ -289,8 +289,8 @@ async function updateUser (req: express.Request, res: express.Response) { return res.sendStatus(204) } -async function askResetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { - const user = res.locals.user as UserModel +async function askResetUserPassword (req: express.Request, res: express.Response) { + const user = res.locals.user const verificationString = await Redis.Instance.setResetPasswordVerificationString(user.id) 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 return res.status(204).end() } -async function resetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { - const user = res.locals.user as UserModel +async function resetUserPassword (req: express.Request, res: express.Response) { + const user = res.locals.user user.password = req.body.password await user.save() @@ -315,16 +315,16 @@ async function sendVerifyUserEmail (user: UserModel) { return } -async function askSendVerifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { - const user = res.locals.user as UserModel +async function askSendVerifyUserEmail (req: express.Request, res: express.Response) { + const user = res.locals.user await sendVerifyUserEmail(user) return res.status(204).end() } -async function verifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { - const user = res.locals.user as UserModel +async function verifyUserEmail (req: express.Request, res: express.Response) { + const user = res.locals.user user.emailVerified = true await user.save() @@ -332,7 +332,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response, nex return res.status(204).end() } -function success (req: express.Request, res: express.Response, next: express.NextFunction) { +function success (req: express.Request, res: express.Response) { res.end() } -- cgit v1.2.3