diff options
Diffstat (limited to 'server/controllers/api/users/index.ts')
-rw-r--r-- | server/controllers/api/users/index.ts | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index 99f51a648..c1d72087c 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -6,7 +6,7 @@ import { getFormattedObjects } from '../../../helpers/utils' | |||
6 | import { RATES_LIMIT, WEBSERVER } from '../../../initializers/constants' | 6 | import { RATES_LIMIT, WEBSERVER } from '../../../initializers/constants' |
7 | import { Emailer } from '../../../lib/emailer' | 7 | import { Emailer } from '../../../lib/emailer' |
8 | import { Redis } from '../../../lib/redis' | 8 | import { Redis } from '../../../lib/redis' |
9 | import { createUserAccountAndChannelAndPlaylist } from '../../../lib/user' | 9 | import { createUserAccountAndChannelAndPlaylist, sendVerifyUserEmail } from '../../../lib/user' |
10 | import { | 10 | import { |
11 | asyncMiddleware, | 11 | asyncMiddleware, |
12 | asyncRetryTransactionMiddleware, | 12 | asyncRetryTransactionMiddleware, |
@@ -147,7 +147,7 @@ usersRouter.post('/:id/reset-password', | |||
147 | usersRouter.post('/ask-send-verify-email', | 147 | usersRouter.post('/ask-send-verify-email', |
148 | askSendEmailLimiter, | 148 | askSendEmailLimiter, |
149 | asyncMiddleware(usersAskSendVerifyEmailValidator), | 149 | asyncMiddleware(usersAskSendVerifyEmailValidator), |
150 | asyncMiddleware(askSendVerifyUserEmail) | 150 | asyncMiddleware(reSendVerifyUserEmail) |
151 | ) | 151 | ) |
152 | 152 | ||
153 | usersRouter.post('/:id/verify-email', | 153 | usersRouter.post('/:id/verify-email', |
@@ -320,14 +320,7 @@ async function resetUserPassword (req: express.Request, res: express.Response) { | |||
320 | return res.status(204).end() | 320 | return res.status(204).end() |
321 | } | 321 | } |
322 | 322 | ||
323 | async function sendVerifyUserEmail (user: UserModel) { | 323 | async function reSendVerifyUserEmail (req: express.Request, res: express.Response) { |
324 | const verificationString = await Redis.Instance.setVerifyEmailVerificationString(user.id) | ||
325 | const url = WEBSERVER.URL + '/verify-account/email?userId=' + user.id + '&verificationString=' + verificationString | ||
326 | await Emailer.Instance.addVerifyEmailJob(user.email, url) | ||
327 | return | ||
328 | } | ||
329 | |||
330 | async function askSendVerifyUserEmail (req: express.Request, res: express.Response) { | ||
331 | const user = res.locals.user | 324 | const user = res.locals.user |
332 | 325 | ||
333 | await sendVerifyUserEmail(user) | 326 | await sendVerifyUserEmail(user) |
@@ -339,6 +332,11 @@ async function verifyUserEmail (req: express.Request, res: express.Response) { | |||
339 | const user = res.locals.user | 332 | const user = res.locals.user |
340 | user.emailVerified = true | 333 | user.emailVerified = true |
341 | 334 | ||
335 | if (req.body.isPendingEmail === true) { | ||
336 | user.email = user.pendingEmail | ||
337 | user.pendingEmail = null | ||
338 | } | ||
339 | |||
342 | await user.save() | 340 | await user.save() |
343 | 341 | ||
344 | return res.status(204).end() | 342 | return res.status(204).end() |