Skip to content
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

Merged
merged 1 commit into from
Jul 11, 2019
Merged

Conversation

chokonaira
Copy link
Contributor

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)

Screenshot 2019-07-06 at 10 48 51 AM

Questions:
-N/A

@@ -0,0 +1,35 @@
import nodemailer from 'nodemailer';
Copy link

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

@@ -0,0 +1,70 @@
/**
Copy link

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

@@ -0,0 +1,57 @@
import jwt from 'jsonwebtoken';
Copy link

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

import Template from '../helpers/mail/MailTemplate';
import Mailer from '../helpers/mail/Mailer';

const { generateToken, comparePassword } = Auth;
Copy link

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

@@ -1,44 +1,101 @@
import auth from '../middleware/Auth';
import passwordHash from 'password-hash';
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 6, 2019 09:55 Inactive
@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from 0e07545 to dc29130 Compare July 6, 2019 19:29
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 6, 2019 19:29 Inactive
@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from dc29130 to 8765f46 Compare July 6, 2019 19:37
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 6, 2019 19:37 Inactive
@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from 8765f46 to 4972b63 Compare July 10, 2019 16:30
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 10, 2019 16:30 Inactive
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
}
}),
down: (queryInterface, Sequelize) => queryInterface.dropTable('Tags')
Copy link

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;
Copy link

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;
Copy link

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

describe('Auth', () => {
before(() => {
const email = ['main.jane@gmail.com', 'main.jane3@gmail.com'];
email.map((i) => {
Copy link

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'),
Copy link

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

@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from 4972b63 to 7e82f2b Compare July 10, 2019 23:16
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 10, 2019 23:16 Inactive
return res.status(201).json({
status: 201,
message: 'A link has been sent to your mailbox for verification',
token
});
} catch (err) {
console.log(err);
Copy link

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

@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from 7e82f2b to beedb87 Compare July 10, 2019 23:25
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 10, 2019 23:25 Inactive
@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from beedb87 to e172c78 Compare July 10, 2019 23:29
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 10, 2019 23:30 Inactive
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';
Copy link
Contributor

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

@@ -25,7 +25,7 @@ export class Auth {
/**
*
*@description Verifies token
* @param { string } token
* @param {*} token
Copy link
Contributor

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();

Copy link
Contributor

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

@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from e172c78 to e1a919a Compare July 11, 2019 11:57
type: Sequelize.DATE
}
}),
down: (queryInterface, Sequelize) => queryInterface.dropTable('Ratings'),
Copy link

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

@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 11, 2019 11:57 Inactive
@chokonaira chokonaira force-pushed the ft-user-signin-route-166841007 branch from e1a919a to 4c732bd Compare July 11, 2019 12:30
@czarjulius czarjulius temporarily deployed to ah-nyati-backend-staging-pr-27 July 11, 2019 12:31 Inactive
Integrate user signin route

[Delivers #166841007]
Copy link
Contributor

@codeBlock-1984 codeBlock-1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job @chokonaira.

@fob413 fob413 merged commit f6d1f2b into staging Jul 11, 2019
@fob413 fob413 deleted the ft-user-signin-route-166841007 branch July 11, 2019 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants