Skip to content

Commit

Permalink
chore(authentication): Add token in the link for activating a user
Browse files Browse the repository at this point in the history
- Integrated the generated token in the link sent through email as a query parameter
[Deleivers #167055602]
  • Loading branch information
ericnyirimana committed Jul 3, 2019
1 parent a97d894 commit 1beecb8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class UserController {

const issueToken = helper.generateToken(user.dataValues);

await userHelper.sendVerificationEmail(email);
await userHelper.sendVerificationEmail(email, issueToken);
return res.status(201).send({
status: 201,
message: 'You have successfully registered. Check you email to validate you account',
Expand Down
3 changes: 2 additions & 1 deletion helpers/userHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ class UserHelper {
* Send verification email
* @function sendVerificationEmail
* @param {string} email - user email
* @param {string} token - token
* @return {boolean} has sent
* @static
*/
static async sendVerificationEmail(email) {
const userToken = helper.tokenGenerator(30);

const link = `${process.env.BASE_URL}/api/v1/users/verification?token=${userToken}&email=${email}`;
const link = `${process.env.FRONTEND_URL}/verification?token=${userToken}&email=${email}`;
const info = {
email,
subject: 'Author Heaven Email Verification',
Expand Down

0 comments on commit 1beecb8

Please sign in to comment.