aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users/index.ts')
-rw-r--r--server/controllers/api/users/index.ts30
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
224async function unblockUser (req: express.Request, res: express.Response, next: express.NextFunction) { 224async 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
232async function blockUser (req: express.Request, res: express.Response) { 232async 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
241function getUser (req: express.Request, res: express.Response) { 241function 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
245async function autocompleteUsers (req: express.Request, res: express.Response) { 245async 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
257async function removeUser (req: express.Request, res: express.Response) { 257async 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
267async function updateUser (req: express.Request, res: express.Response) { 267async 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
292async function askResetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { 292async 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
302async function resetUserPassword (req: express.Request, res: express.Response, next: express.NextFunction) { 302async 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
318async function askSendVerifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { 318async 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
326async function verifyUserEmail (req: express.Request, res: express.Response, next: express.NextFunction) { 326async 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
335function success (req: express.Request, res: express.Response, next: express.NextFunction) { 335function success (req: express.Request, res: express.Response) {
336 res.end() 336 res.end()
337} 337}
338 338