-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,251 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,5 @@ typings/ | |
.next | ||
|
||
secretKey.js | ||
|
||
config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
const nodemailer = require('nodemailer') | ||
|
||
exports.verifyEmail = async (email,host,token)=>{ | ||
let transporter = nodemailer.createTransport({ service: process.env.GMAIL_SERVICE, | ||
port: process.env.PORT, | ||
secure :false, | ||
auth:{ user: process.env.GMAIL_USER, pass: process.env.GMAIL_PASSWORD } }); | ||
let mailOptions = { | ||
from : '[email protected]', | ||
to: email, | ||
subject: 'Account Verification Token', | ||
text: 'Hello,\n\n' + 'Please verify your account by clicking the link: \nhttp:\/\/' + host + '\/mentors\/confirmation/?token=' + token + '.\n' }; | ||
await transporter.sendMail(mailOptions,(err)=> { | ||
if (err) { | ||
return console.log(err) | ||
} | ||
const path = require('path'); | ||
var EmailTemplate = require('email-templates'); | ||
exports.verifyEmail = async (email, host, token) => { | ||
let transporter = nodemailer.createTransport({ | ||
service: process.env.GMAIL_SERVICE, | ||
port: process.env.PORT, | ||
secure: false, | ||
auth: { user: process.env.GMAIL_USER, pass: process.env.GMAIL_PASSWORD } | ||
}); | ||
const emails = new EmailTemplate({ | ||
send: true, | ||
message: { | ||
from: process.env.GMAIL_USER | ||
}, | ||
transport: transporter, | ||
preview: false | ||
}); | ||
emails.send({ | ||
template: path.join(__dirname, '..', 'email', 'mentors'), | ||
message: { | ||
to: email | ||
}, | ||
locals: { | ||
host: host, | ||
token: token | ||
} | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
doctype html | ||
html | ||
body | ||
p Hello, Please verify your account by clicking the link: http:\\' + #{host} + '\mentors\confirmation/?token=' + #{token}. | ||
p Hello, Please verify your account by clicking the link: | ||
a(href = `http://${host}/mentors/confirmation/?token=${token}`) Verify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
const { body } = require('express-validator/check') | ||
const User = require('../models/user') | ||
|
||
exports.validate = (method) => { | ||
switch (method) { | ||
case 'createUser': | ||
return [ | ||
body('email', 'Email already exists').exists(), | ||
case 'createUser': | ||
return [ | ||
body('email').custom(async (value, { req }) => { | ||
let user = await User.findOne({ email: req.body.email }) | ||
if (user) { | ||
throw new Error('Email already exists'); | ||
} | ||
return true; | ||
}), | ||
body('email', 'Invalid email').isEmail(), | ||
body('first_name','First name should not be empty').not().isEmpty(), | ||
body('last_name','Last name should not be empty').not().isEmpty(), | ||
body('password','Password name should not be empty').not().isEmpty(), | ||
body('password').custom((value , { req }) => { | ||
if (value !== req.body.confirm_password) { | ||
body('first_name', 'First name should not be empty').not().isEmpty(), | ||
body('last_name', 'Last name should not be empty').not().isEmpty(), | ||
body('password', 'Password name should not be empty').not().isEmpty(), | ||
This comment has been minimized.
Sorry, something went wrong. |
||
body('password').custom((value, { req }) => { | ||
if (value !== req.body.confirm_password) { | ||
throw new Error('Password confirmation is incorrect'); | ||
} | ||
return true; | ||
}), | ||
body('password','Invalid Password').matches('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})') | ||
body('password', 'Invalid Password').matches('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})'), | ||
// body('password', 'Invalid Password').custom((value, { req }) => { | ||
// if (body('password').contains(req.body.first_name) ){ | ||
// throw new Error('Password should not contains name/email'); | ||
// } | ||
// return true; | ||
// }), | ||
body('user_role', 'Invalid user role').isBoolean() | ||
] | ||
} | ||
} |
Oops, something went wrong.
name?