-
Notifications
You must be signed in to change notification settings - Fork 7
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
9 changed files
with
1,595 additions
and
1,409 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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,13 +1,36 @@ | ||
import db from '../models'; | ||
import db from '../models/User'; | ||
import { Sequelize, sequelize } from '../models/index'; | ||
import SendEmail from '../utils/HelperMethods'; | ||
|
||
const Users = db(sequelize, Sequelize.DataTypes); | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const signUp = async (req, res) => { | ||
try { | ||
const user = await db.User.create(req.body); | ||
res.status(201).json({ user }); | ||
const isVerified = false; | ||
const { | ||
email, firstName, lastName, password | ||
} = req.body; | ||
const user = await Users.create({ | ||
email, | ||
firstName, | ||
lastName, | ||
password, | ||
isVerified, | ||
}); | ||
const url = 'localhost:3000/;'; | ||
SendEmail(email, firstName, url); | ||
res.status(201).json({ | ||
success: true, | ||
message: 'Your account has been successfully created. An email has been sent to you with detailed instructions on how to activate it.', | ||
data: user | ||
}); | ||
} catch (err) { | ||
const status = 400; | ||
const error = err.errors[0].message; | ||
res.status(status).json({ status, error }); | ||
} | ||
}; | ||
|
||
export const verifiedUser = async (req, res) => { | ||
} |
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,20 +1,37 @@ | ||
import { Sequelize, sequelize } from '../models/index'; | ||
import db from '../models/User'; | ||
import { Sequelize, sequelize } from '../models'; | ||
import SendEmail from '../utils/HelperMethods'; | ||
|
||
const Users = require('../models/User')(sequelize, Sequelize.DataTypes); | ||
const Users = db(sequelize, Sequelize.DataTypes); | ||
|
||
const timeStamp = Date.now().toString(); | ||
const id = Math.round(parseInt(timeStamp, 10) / 1000); | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const signUp = async (req, res) => { | ||
try { | ||
const isVerified = false; | ||
|
||
module.exports = { | ||
create(req, res) { | ||
const { name, email, password } = req.body; | ||
return Users.create({ | ||
name, | ||
const { | ||
email, firstName, lastName, password | ||
} = req.body; | ||
const user = await Users.create({ | ||
email, | ||
firstName, | ||
lastName, | ||
password, | ||
id | ||
}) | ||
.then(user => res.status(201).send(user)) | ||
.catch(error => res.status(400).send(error)); | ||
isVerified, | ||
}); | ||
const url = 'localhost:3000/;'; | ||
SendEmail(email, firstName, url); | ||
res.status(201).json({ | ||
success: true, | ||
message: 'Your account has been successfully created. An email has been sent to you with detailed instructions on how to activate it.', | ||
data: user | ||
}); | ||
} catch (err) { | ||
const status = 400; | ||
const error = err.errors[0].message; | ||
res.status(status).json({ status, error }); | ||
} | ||
}; | ||
|
||
export const verifiedUser = async (req, res) => { | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sgMail from '@sendgrid/mail'; | ||
|
||
const sendEMail = (email, firstName, url) => { | ||
sgMail.setApiKey(process.env.SENDGRID_API_KEY); | ||
|
||
const msg = { | ||
to: email, | ||
from: process.env.PROJECT_EMAIL, | ||
subject: 'Verify Your Email', | ||
text: 'Welcome to Barefoot Nomad, please verify your email below', | ||
html: `'<div style="width: 90%; margin: 5em auto; box-shadow: 0 0 10px rgba(0,0,0,.9);"> | ||
<div> | ||
<div> | ||
<div style="background-color: #2084ba; height: 3rem; width: 100%"> | ||
<h2 style="text-align: center; color: white; padding-top: 10px;">Barefoot Nomad</h2> | ||
</div> | ||
<h4 style="text-align: center">Hi! ${firstName}</h4> | ||
</div> | ||
<div style=" padding: 0px 20px 20px 20px"> | ||
<div> | ||
<p>Please verify that your email <strong>${email}</strong> when you signed up.</p> | ||
<p>Click on the button below to verify.</p> | ||
<button style="color: white; background-color: #2084ba; border: none; border-radius: 10px; text-align: center; padding: 10px;"><a href="${url}" style="text-decoration: none; color: white;">Verify Account</a></button> | ||
</div> | ||
<div> | ||
<h3 style="text-align: center">Thank you</h3> | ||
<h3 style="text-align: center">Please do not reply, this is an autogenerated email.</h3> | ||
</div> | ||
</div> | ||
</div> | ||
</div>`, | ||
}; | ||
sgMail.send(msg); | ||
return true; | ||
}; | ||
|
||
export default sendEMail; |
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