-
Notifications
You must be signed in to change notification settings - Fork 8
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
#166841007 User signin endpoint #27
Conversation
src/helpers/mail/Mailer.js
Outdated
@@ -0,0 +1,35 @@ | |||
import nodemailer from 'nodemailer'; |
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.
Definition for rule 'jsx-a11y/anchor-is-valid' was not found jsx-a11y/anchor-is-valid
src/helpers/mail/MailTemplate.js
Outdated
@@ -0,0 +1,70 @@ | |||
/** |
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.
Definition for rule 'jsx-a11y/anchor-is-valid' was not found jsx-a11y/anchor-is-valid
src/helpers/helpers.js
Outdated
@@ -0,0 +1,57 @@ | |||
import jwt from 'jsonwebtoken'; |
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.
Definition for rule 'jsx-a11y/anchor-is-valid' was not found jsx-a11y/anchor-is-valid
src/controllers/Auth.js
Outdated
import Template from '../helpers/mail/MailTemplate'; | ||
import Mailer from '../helpers/mail/Mailer'; | ||
|
||
const { generateToken, comparePassword } = Auth; |
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.
'comparePassword' is assigned a value but never used no-unused-vars
src/controllers/Auth.js
Outdated
@@ -1,44 +1,101 @@ | |||
import auth from '../middleware/Auth'; | |||
import passwordHash from 'password-hash'; |
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.
Definition for rule 'jsx-a11y/anchor-is-valid' was not found jsx-a11y/anchor-is-valid
0e07545
to
dc29130
Compare
dc29130
to
8765f46
Compare
8765f46
to
4972b63
Compare
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') | ||
} | ||
}), | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('Tags') |
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.
'Sequelize' is defined but never used no-unused-vars
.end((err, res) => { | ||
token = res.body.data; | ||
token = res.body.token; |
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.
Multiple spaces found before '=' no-multi-spaces
Use object destructuring prefer-destructuring
chai.request(app).post('/api/v1/auth/login') | ||
.send(existingUser) | ||
.end((err, res) => { | ||
token = res.body.token; |
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.
Use object destructuring prefer-destructuring
test/auth.test.js
Outdated
describe('Auth', () => { | ||
before(() => { | ||
const email = ['main.jane@gmail.com', 'main.jane3@gmail.com']; | ||
email.map((i) => { |
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.
Expected to return a value in arrow function array-callback-return
type: Sequelize.DATE | ||
} | ||
}), | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('Likes'), |
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.
'Sequelize' is defined but never used no-unused-vars
4972b63
to
7e82f2b
Compare
src/controllers/Auth.js
Outdated
return res.status(201).json({ | ||
status: 201, | ||
message: 'A link has been sent to your mailbox for verification', | ||
token | ||
}); | ||
} catch (err) { | ||
console.log(err); |
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.
Unexpected console statement no-console
7e82f2b
to
beedb87
Compare
beedb87
to
e172c78
Compare
src/controllers/Auth.js
Outdated
import { Blacklist, User } from '../db/models'; | ||
import template from '../helpers/mail/mailTemplate/signupEmailTemplate'; | ||
import sendEmail from '../helpers/mail/mailer'; | ||
|
||
const { generateToken, verifyToken } = Auth; | ||
|
||
dotenv.config(); | ||
const isTest = process.env.NODE_ENV === 'test'; |
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 come from the config.js file
src/helpers/helpers.js
Outdated
@@ -25,7 +25,7 @@ export class Auth { | |||
/** | |||
* | |||
*@description Verifies token | |||
* @param { string } token | |||
* @param {*} token |
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.
please revert this change with what is on staging
) | ||
); | ||
dotenv.config(); | ||
|
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.
please revert this change with what is on staging
e172c78
to
e1a919a
Compare
type: Sequelize.DATE | ||
} | ||
}), | ||
down: (queryInterface, Sequelize) => queryInterface.dropTable('Ratings'), |
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.
'Sequelize' is defined but never used no-unused-vars
e1a919a
to
4c732bd
Compare
Integrate user signin route [Delivers #166841007]
4c732bd
to
2c7faab
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.
Nice job @chokonaira.
What does this PR do?
-An endpoint for existing users to sign in on Authors Heaven
Description of Task to be completed?
-Integrated JWT for authentication - user sign-in route
How should this be manually tested?
-git clone https://github.com/andela/ah-nyati-backend.git
-navigate to http://localhost:3000/api/v1/auth/login
Any background context you want to provide?
N/A
What are the relevant pivotal tracker stories?
#166841007
Screenshots (if appropriate)
Questions:
-N/A