-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#167484585 implemented email verification link approach #14
Conversation
src/helpers/mailer.js
Outdated
@@ -0,0 +1,45 @@ | |||
import dotenv from 'dotenv'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
a74e835
to
f0a4ac4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about you Placide, but I've tested this on my pc and it's not sending me a verification email. I used my two email addresses, and none has sent. Any reason why this is happening?
If you don't get the email in your inbox. You should check your Spam folder. It should be there! |
Could you please include that and the Environment variable in the PR as suggested by @mkiterian earlier? |
Yes, I have done that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, I think It's not necessary to put postman when sending a verification email. Because somebody maybe using another API testing app or browser extension like Restman and still works.
Thank you for mentioning that! I'm gonna remove Postman. |
… user registration
src/helpers/mailer.js
Outdated
mailer.send(message); | ||
} | ||
}; | ||
// eslint-disable-next-line import/prefer-default-export |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why disable this eslint rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, When I used export default, the function didn't get detected. But, I have improved the way I use it in the user controller and it is working. So, I can re-enable the rule.
.env.sample
Outdated
@@ -6,3 +6,6 @@ DB_NAME_TEST= | |||
DB_PORT= | |||
DATABASE_URL= | |||
SECRET_KEY= | |||
SENDGRID_API_KEY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the spaces preceding the =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I have removed the free spaces in .env.sample.
src/helpers/mailer.js
Outdated
from: EMAIL_SENDER, | ||
subject: subjectVerify, | ||
text: 'Authors Haven', | ||
html: `<div style="background:#ECF0F1;width:100%;padding:20px 0;"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd much rather this markup string is generated by a function e.g createEmailTemplate(contentVerify, linkVerify)
and used here. Would make it much cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I'm going to implement that approach. It is really good.
f0a4ac4
to
8de0f54
Compare
src/helpers/templates/mail.js
Outdated
return message; | ||
}; | ||
|
||
export default createEmailTemplate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
8de0f54
to
2805434
Compare
…ah-backend into ft-verify-email-167484585
2805434
to
29113a1
Compare
@@ -1,20 +1,31 @@ | |||
import dotenv from 'dotenv'; | |||
import { config } from 'dotenv'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/controllers/verifyEmail.js
Outdated
@@ -0,0 +1,15 @@ | |||
import { User } from '../sequelize/models/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
29113a1
to
e0a716a
Compare
src/sequelize/models/User.js
Outdated
@@ -33,6 +33,11 @@ export default (sequelize, DataTypes) => { | |||
type: DataTypes.STRING, | |||
defaultValue: 'user', | |||
}, | |||
status: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a boolean field since we expect it to only have two states. You can name it either active
/verified
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have implemented that.
src/controllers/verifyEmail.js
Outdated
@@ -0,0 +1,15 @@ | |||
import { User } from '../sequelize/models/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of the userController
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excuse me... You mean the whole code inside the verifyEmail.js file, should be inside the userController.js file? Or, that single line of importing from sequelize should be inside the userController?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the whole code inside the verifyEmail.js file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
e0a716a
to
c72b287
Compare
src/controllers/userController.js
Outdated
@@ -11,6 +11,7 @@ config(); | |||
*/ | |||
class Authentication { | |||
/** | |||
* Eric MALABA & Placide IRANDORA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! It should be @author Eric MALABA & Placide IRANDORA. I tried to indicate the developers who worked on that method/function. But, I'm gonna removed it if it is not necessary.
src/controllers/userController.js
Outdated
@@ -84,7 +103,7 @@ class Authentication { | |||
} | |||
|
|||
/** | |||
* | |||
* @author Carlos HARERIMANA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay!
src/controllers/userController.js
Outdated
@@ -60,6 +61,24 @@ class Authentication { | |||
} | |||
|
|||
/** | |||
* @author Placide IRANDORA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove @author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay!
@@ -33,6 +33,11 @@ export default (sequelize, DataTypes) => { | |||
type: DataTypes.STRING, | |||
defaultValue: 'user', | |||
}, | |||
verified: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the datatype should be DataTypes.BOOLEAN
. We expect a user to either be verified or not. A True vs False value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna implement that.
c72b287
to
fcf0286
Compare
fcf0286
to
2449697
Compare
src/routes/routes.js
Outdated
@@ -6,6 +6,7 @@ import verifyToken from '../middleware/verifyToken'; | |||
const router = express.Router(); | |||
|
|||
router.post('/api/v1/users', Validation.signupValidation, UserAuth.signup); | |||
router.post('/api/v1/verify-email/:token', verifyToken, UserAuth.verifyEmail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a GET
route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I'm gonna implement that.
2449697
to
7b48112
Compare
7b48112
to
218956a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
What does this PR do?
It implements the approach of sending an email verification link to the user upon a successful registration.
Description of Task to be done?
Screenshots
How should this be manually tested?