From f5d873ba57d04c1c592215b850469a8ee98a7e40 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 31 Jan 2017 13:45:23 -0700 Subject: [PATCH] use referer from headers --- routes/api/users/index.js | 11 ++++------- services/users.js | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/routes/api/users/index.js b/routes/api/users/index.js index d41717e9b..6da7b9a4b 100644 --- a/routes/api/users/index.js +++ b/routes/api/users/index.js @@ -118,12 +118,8 @@ const SendEmailConfirmation = (app, userID, email, referer) => UsersService // create a local user. router.post('/', (req, res, next) => { - const { - email, - password, - redirectUri, - displayName - } = req.body; + const {email, password, displayName} = req.body; + const redirectUri = req.header('Referer'); UsersService .createLocalUser(email, password, displayName) @@ -184,6 +180,7 @@ router.post('/:user_id/actions', authorization.needed(), (req, res, next) => { // trigger an email confirmation re-send by a new user router.post('/resend-confirm', (req, res, next) => { const {email} = req.body; + const redirectUri = req.header('Referer'); if (!email) { return next(errors.ErrMissingEmail); @@ -192,7 +189,7 @@ router.post('/resend-confirm', (req, res, next) => { // find user by email. // if the local profile is verified, return an error code? // send a 204 after the email is re-sent - SendEmailConfirmation(req.app, null, email, process.env.TALK_ROOT_URL) + SendEmailConfirmation(req.app, null, email, redirectUri) .then(() => { res.status(204).end(); }) diff --git a/services/users.js b/services/users.js index e84e4f4d7..03fcf16d1 100644 --- a/services/users.js +++ b/services/users.js @@ -538,7 +538,7 @@ module.exports = class UsersService { * @param {String} email The email that we are needing to get confirmed. * @return {Promise} */ - static createEmailConfirmToken(userID = null, email, referer) { + static createEmailConfirmToken(userID = null, email, referer = process.env.TALK_ROOT_URL) { if (!email || typeof email !== 'string') { return Promise.reject('email is required when creating a JWT for resetting passord'); }