aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users/index.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/controllers/api/users/index.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/controllers/api/users/index.ts')
-rw-r--r--server/controllers/api/users/index.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index 5b113feac..d743a9912 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -52,6 +52,7 @@ import { myVideosHistoryRouter } from './my-history'
52import { myNotificationsRouter } from './my-notifications' 52import { myNotificationsRouter } from './my-notifications'
53import { mySubscriptionsRouter } from './my-subscriptions' 53import { mySubscriptionsRouter } from './my-subscriptions'
54import { myVideoPlaylistsRouter } from './my-video-playlists' 54import { myVideoPlaylistsRouter } from './my-video-playlists'
55import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
55 56
56const auditLogger = auditLoggerFactory('users') 57const auditLogger = auditLoggerFactory('users')
57 58
@@ -255,7 +256,7 @@ async function registerUser (req: express.Request, res: express.Response) {
255 256
256 Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel }) 257 Hooks.runAction('action:api.user.registered', { body, user, account, videoChannel })
257 258
258 return res.type('json').status(204).end() 259 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
259} 260}
260 261
261async function unblockUser (req: express.Request, res: express.Response) { 262async function unblockUser (req: express.Request, res: express.Response) {
@@ -265,7 +266,7 @@ async function unblockUser (req: express.Request, res: express.Response) {
265 266
266 Hooks.runAction('action:api.user.unblocked', { user }) 267 Hooks.runAction('action:api.user.unblocked', { user })
267 268
268 return res.status(204).end() 269 return res.status(HttpStatusCode.NO_CONTENT_204).end()
269} 270}
270 271
271async function blockUser (req: express.Request, res: express.Response) { 272async function blockUser (req: express.Request, res: express.Response) {
@@ -276,7 +277,7 @@ async function blockUser (req: express.Request, res: express.Response) {
276 277
277 Hooks.runAction('action:api.user.blocked', { user }) 278 Hooks.runAction('action:api.user.blocked', { user })
278 279
279 return res.status(204).end() 280 return res.status(HttpStatusCode.NO_CONTENT_204).end()
280} 281}
281 282
282function getUser (req: express.Request, res: express.Response) { 283function getUser (req: express.Request, res: express.Response) {
@@ -310,7 +311,7 @@ async function removeUser (req: express.Request, res: express.Response) {
310 311
311 Hooks.runAction('action:api.user.deleted', { user }) 312 Hooks.runAction('action:api.user.deleted', { user })
312 313
313 return res.sendStatus(204) 314 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
314} 315}
315 316
316async function updateUser (req: express.Request, res: express.Response) { 317async function updateUser (req: express.Request, res: express.Response) {
@@ -338,7 +339,7 @@ async function updateUser (req: express.Request, res: express.Response) {
338 339
339 // Don't need to send this update to followers, these attributes are not federated 340 // Don't need to send this update to followers, these attributes are not federated
340 341
341 return res.sendStatus(204) 342 return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
342} 343}
343 344
344async function askResetUserPassword (req: express.Request, res: express.Response) { 345async function askResetUserPassword (req: express.Request, res: express.Response) {
@@ -348,7 +349,7 @@ async function askResetUserPassword (req: express.Request, res: express.Response
348 const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString 349 const url = WEBSERVER.URL + '/reset-password?userId=' + user.id + '&verificationString=' + verificationString
349 await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url) 350 await Emailer.Instance.addPasswordResetEmailJob(user.username, user.email, url)
350 351
351 return res.status(204).end() 352 return res.status(HttpStatusCode.NO_CONTENT_204).end()
352} 353}
353 354
354async function resetUserPassword (req: express.Request, res: express.Response) { 355async function resetUserPassword (req: express.Request, res: express.Response) {
@@ -358,7 +359,7 @@ async function resetUserPassword (req: express.Request, res: express.Response) {
358 await user.save() 359 await user.save()
359 await Redis.Instance.removePasswordVerificationString(user.id) 360 await Redis.Instance.removePasswordVerificationString(user.id)
360 361
361 return res.status(204).end() 362 return res.status(HttpStatusCode.NO_CONTENT_204).end()
362} 363}
363 364
364async function reSendVerifyUserEmail (req: express.Request, res: express.Response) { 365async function reSendVerifyUserEmail (req: express.Request, res: express.Response) {
@@ -366,7 +367,7 @@ async function reSendVerifyUserEmail (req: express.Request, res: express.Respons
366 367
367 await sendVerifyUserEmail(user) 368 await sendVerifyUserEmail(user)
368 369
369 return res.status(204).end() 370 return res.status(HttpStatusCode.NO_CONTENT_204).end()
370} 371}
371 372
372async function verifyUserEmail (req: express.Request, res: express.Response) { 373async function verifyUserEmail (req: express.Request, res: express.Response) {
@@ -380,7 +381,7 @@ async function verifyUserEmail (req: express.Request, res: express.Response) {
380 381
381 await user.save() 382 await user.save()
382 383
383 return res.status(204).end() 384 return res.status(HttpStatusCode.NO_CONTENT_204).end()
384} 385}
385 386
386async function changeUserBlock (res: express.Response, user: MUserAccountDefault, block: boolean, reason?: string) { 387async function changeUserBlock (res: express.Response, user: MUserAccountDefault, block: boolean, reason?: string) {