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

#166816103 Enable social login #21

Merged
merged 1 commit into from
Jul 11, 2019

Conversation

halimahO
Copy link
Contributor

@halimahO halimahO commented Jul 8, 2019

What does this PR do?

Enable facebook login/signup

Description of Task to be completed?

  • Create facebook/google/twitter apps and generate Ids and secret keys
  • Setup middleware(passport)that interfaces with the social sites
  • Create controller function that returns user token after successful login/signup
  • Write unit tests

How should this be manually tested?

For facebook: request to be a tester
For twitter
For google

Any background context you want to provide?

For Facebook login: The feature can only be tested by registered testers while still in the development mode. This configuration is set by facebook for security reasons. But when it goes into production, any facebook user can test out the feature.

What are the relevant pivotal tracker stories?

#166816103

Questions:

None

it('Should return an error 400 when getting all users', () => {
const request = {};
const response = new Response();
sinon.stub(response, 'status').returnsThis();
Copy link

Choose a reason for hiding this comment

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

Replace 'status' with "status" prettier/prettier

@@ -192,6 +258,14 @@ describe('Auth API endpoints', () => {
expect(response).to.have.status(400);
expect(response.body.status).to.equal('fail');
});

it('Should return an error 400 when getting all users', () => {
Copy link

Choose a reason for hiding this comment

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

Replace 'Should·return·an·error·400·when·getting·all·users' with "Should·return·an·error·400·when·getting·all·users" prettier/prettier

expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
expect(response.body.data[0].msg).to.equal(
'Password can not be less than 8 characters'
Copy link

Choose a reason for hiding this comment

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

Replace 'Password·can·not·be·less·than·8·characters' with "Password·can·not·be·less·than·8·characters" prettier/prettier

expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
Copy link

Choose a reason for hiding this comment

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

Replace 'fail' with "fail" prettier/prettier

.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
Copy link

Choose a reason for hiding this comment

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

Replace 'data' with "data" prettier/prettier

});
});

it('Should not allow invalid password user input', done => {
Copy link

Choose a reason for hiding this comment

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

Replace 'Should·not·allow·invalid·password·user·input' with "Should·not·allow·invalid·password·user·input" prettier/prettier

expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
expect(response.body.data[0].msg).to.equal(
'Last name must be only alphabetical chars'
Copy link

Choose a reason for hiding this comment

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

Replace 'Last·name·must·be·only·alphabetical·chars' with "Last·name·must·be·only·alphabetical·chars" prettier/prettier

expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
Copy link

Choose a reason for hiding this comment

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

Replace 'fail' with "fail" prettier/prettier

.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
Copy link

Choose a reason for hiding this comment

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

Replace 'data' with "data" prettier/prettier

})
.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
Copy link

Choose a reason for hiding this comment

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

Replace 'status' with "status" prettier/prettier

@@ -3,7 +3,7 @@ import chaiHttp from 'chai-http';
import dotenv from 'dotenv';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import getToken from '../../helpers/jwt.helper';
import { getToken } from '../../helpers/jwt.helper';
Copy link

Choose a reason for hiding this comment

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

Replace '../../helpers/jwt.helper' with "../../helpers/jwt.helper" prettier/prettier

@@ -6,3 +6,4 @@ import './middleware/auth.spec';
import './models/user.spec';
import './controller/auth.spec';
import './controller/user.spec';
import './controller/social.spec';
Copy link

Choose a reason for hiding this comment

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

Replace './controller/social.spec' with "./controller/social.spec" prettier/prettier

const tokenMock = 'fake.token';

sinon.spy(Helper, 'successResponse');
sinon.stub(jwtHelper, 'getToken').returns(tokenMock);
Copy link

Choose a reason for hiding this comment

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

Replace 'getToken' with "getToken" prettier/prettier


const tokenMock = 'fake.token';

sinon.spy(Helper, 'successResponse');
Copy link

Choose a reason for hiding this comment

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

Replace 'successResponse' with "successResponse" prettier/prettier

roleType: 'guest'
};

const tokenMock = 'fake.token';
Copy link

Choose a reason for hiding this comment

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

Replace 'fake.token' with "fake.token" prettier/prettier

json() {}
};

it('responds with 400 for user with no email', async () => {
Copy link

Choose a reason for hiding this comment

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

Replace 'responds·with·400·for·user·with·no·email' with "responds·with·400·for·user·with·no·email" prettier/prettier

});
});

describe('socialRedirect', () => {
Copy link

Choose a reason for hiding this comment

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

Replace 'socialRedirect' with "socialRedirect" prettier/prettier

}
};

sinon.stub(User, 'findOrCreate').returns([userMock]);
Copy link

Choose a reason for hiding this comment

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

Replace 'findOrCreate' with "findOrCreate" prettier/prettier

profileMock.emails = [{ value: 'johndoe@mail.com' }];
const userMock = {
dataValues: {
email: 'johndoe@mail.com'
Copy link

Choose a reason for hiding this comment

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

Replace 'johndoe@mail.com' with "johndoe@mail.com" prettier/prettier


it('successfully authenticate and get/create user', async () => {
const done = sinon.spy();
profileMock.emails = [{ value: 'johndoe@mail.com' }];
Copy link

Choose a reason for hiding this comment

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

Replace 'johndoe@mail.com' with "johndoe@mail.com" prettier/prettier

expect(done).calledOnceWith(null, { noEmail: true });
});

it('successfully authenticate and get/create user', async () => {
Copy link

Choose a reason for hiding this comment

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

Replace 'successfully·authenticate·and·get/create·user' with "successfully·authenticate·and·get/create·user" prettier/prettier

photos: [{ value: 'img.io' }]
};

it('responds with no email', async () => {
Copy link

Choose a reason for hiding this comment

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

Replace 'responds·with·no·email' with "responds·with·no·email" prettier/prettier

id: '122',
displayName: 'john doe',
provider: 'AH',
photos: [{ value: 'img.io' }]
Copy link

Choose a reason for hiding this comment

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

Replace 'img.io' with "img.io" prettier/prettier

const profileMock = {
id: '122',
displayName: 'john doe',
provider: 'AH',
Copy link

Choose a reason for hiding this comment

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

Replace 'AH' with "AH" prettier/prettier

describe('socialCallback', () => {
const profileMock = {
id: '122',
displayName: 'john doe',
Copy link

Choose a reason for hiding this comment

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

Replace 'john·doe' with "john·doe" prettier/prettier

import {
socialCallback,
socialRedirect
} from '../../controllers/social.controller';
Copy link

Choose a reason for hiding this comment

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

Replace '../../controllers/social.controller' with "../../controllers/social.controller" prettier/prettier

@@ -0,0 +1,87 @@
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import chai, { expect } from 'chai';
Copy link

Choose a reason for hiding this comment

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

Replace 'chai' with "chai" prettier/prettier

@@ -0,0 +1,87 @@
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
Copy link

Choose a reason for hiding this comment

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

Replace 'sinon-chai' with "sinon-chai" prettier/prettier

@@ -0,0 +1,87 @@
import sinon from 'sinon';
Copy link

Choose a reason for hiding this comment

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

Replace 'sinon' with "sinon" prettier/prettier

@@ -1,6 +1,6 @@
import bcrypt from 'bcryptjs';
import crypto from 'crypto';
import getToken from '../helpers/jwt.helper';
import { getToken } from '../helpers/jwt.helper';
Copy link

Choose a reason for hiding this comment

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

Replace '../helpers/jwt.helper' with "../helpers/jwt.helper" prettier/prettier

@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from 7529bd4 to 5b8d24f Compare July 9, 2019 07:47
@@ -1,6 +1,6 @@
import bcrypt from 'bcryptjs';
import crypto from 'crypto';
import getToken, { getPasswordResetToken } from '../helpers/jwt.helper';
import { getToken, getPasswordResetToken } from '../helpers/jwt.helper';
Copy link

Choose a reason for hiding this comment

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

Replace '../helpers/jwt.helper' with "../helpers/jwt.helper" prettier/prettier


router
.get('/google', passport.authenticate('google', { scope: ['email'] }))
.get('/google/callback', passport.authenticate('google'), socialRedirect);
Copy link

Choose a reason for hiding this comment

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

Replace '/google/callback',·passport.authenticate('google' with "/google/callback",·passport.authenticate("google" prettier/prettier

);

router
.get('/google', passport.authenticate('google', { scope: ['email'] }))
Copy link

Choose a reason for hiding this comment

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

Replace '/google',·passport.authenticate('google',·{·scope:·['email' with "/google",·passport.authenticate("google",·{·scope:·["email" prettier/prettier

.get('/twitter', passport.authenticate('twitter', { scope: ['email'] }))
.get(
'/twitter/callback',
passport.authenticate('twitter', { session: false }),
Copy link

Choose a reason for hiding this comment

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

Replace 'twitter' with "twitter" prettier/prettier

router
.get('/twitter', passport.authenticate('twitter', { scope: ['email'] }))
.get(
'/twitter/callback',
Copy link

Choose a reason for hiding this comment

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

Replace '/twitter/callback' with "/twitter/callback" prettier/prettier

@@ -0,0 +1,27 @@
import express from 'express';
Copy link

Choose a reason for hiding this comment

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

Replace 'express' with "express" prettier/prettier


export default app => {
app.use('/api/v1/auth/', socialAuth);
Copy link

Choose a reason for hiding this comment

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

Replace '/api/v1/auth/' with "/api/v1/auth/" prettier/prettier

@@ -1,7 +1,9 @@
import auth from './auth.route';
import users from './user.route';
import socialAuth from './social.route';
Copy link

Choose a reason for hiding this comment

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

Replace './social.route' with "./social.route" prettier/prettier

import swaggerConfig from '../swagger.json';
import Routes from './routes/v1';
import './config/passportStrategies';
Copy link

Choose a reason for hiding this comment

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

Replace './config/passportStrategies' with "./config/passportStrategies" prettier/prettier

@@ -2,16 +2,27 @@ import express from 'express';
import bodyParser from 'body-parser';
import swagger from 'swagger-ui-express';
import logger from 'morgan';
import passport from 'passport';
import session from 'express-session';
Copy link

Choose a reason for hiding this comment

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

Replace 'express-session' with "express-session" prettier/prettier

@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from 5b8d24f to d1ccde4 Compare July 9, 2019 11:56
expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
expect(response.body.data[0].msg).to.equal(
'Last name must be only alphabetical chars'
Copy link

Choose a reason for hiding this comment

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

Replace 'Last·name·must·be·only·alphabetical·chars' with "Last·name·must·be·only·alphabetical·chars" prettier/prettier

expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
Copy link

Choose a reason for hiding this comment

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

Replace 'fail' with "fail" prettier/prettier

.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
Copy link

Choose a reason for hiding this comment

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

Replace 'data' with "data" prettier/prettier

})
.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
Copy link

Choose a reason for hiding this comment

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

Replace 'status' with "status" prettier/prettier

.send({
email: 'sandy@gmail.com',
password: 'samsss',
firstName: 'gfhshs',
Copy link

Choose a reason for hiding this comment

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

Replace 'gfhshs' with "gfhshs" prettier/prettier

.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
Copy link

Choose a reason for hiding this comment

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

Replace 'data' with "data" prettier/prettier

})
.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
Copy link

Choose a reason for hiding this comment

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

Replace 'status' with "status" prettier/prettier

email: 'sandy@gmail.com',
password: 'samsss',
firstName: 23,
lastName: 'ghghghg'
Copy link

Choose a reason for hiding this comment

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

Replace 'ghghghg' with "ghghghg" prettier/prettier

.post('/api/v1/users/signup')
.send({
email: 'sandy@gmail.com',
password: 'samsss',
Copy link

Choose a reason for hiding this comment

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

Replace 'samsss' with "samsss" prettier/prettier

.request(app)
.post('/api/v1/users/signup')
.send({
email: 'sandy@gmail.com',
Copy link

Choose a reason for hiding this comment

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

Replace 'sandy@gmail.com' with "sandy@gmail.com" prettier/prettier

@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from d1ccde4 to d60b406 Compare July 9, 2019 12:12
it('Should not allow duplicated user register', done => {
chai
.request(app)
.post('/api/v1/users/signup')
Copy link

Choose a reason for hiding this comment

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

Replace '/api/v1/users/signup' with "/api/v1/users/signup" prettier/prettier

});
});

it('Should not allow duplicated user register', done => {
Copy link

Choose a reason for hiding this comment

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

Replace 'Should·not·allow·duplicated·user·register' with "Should·not·allow·duplicated·user·register" prettier/prettier

expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
expect(response.body.data[0].msg).to.equal(
'Password can not be less than 8 characters'
Copy link

Choose a reason for hiding this comment

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

Replace 'Password·can·not·be·less·than·8·characters' with "Password·can·not·be·less·than·8·characters" prettier/prettier

expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
expect(response.body.status).to.equal('fail');
Copy link

Choose a reason for hiding this comment

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

Replace 'fail' with "fail" prettier/prettier

.end((error, response) => {
expect(response.status).to.equal(400);
expect(response.body).to.have.property('status');
expect(response.body).to.have.property('data');
Copy link

Choose a reason for hiding this comment

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

Replace 'data' with "data" prettier/prettier

@@ -178,6 +178,72 @@ describe('Auth API endpoints', () => {
});
});

it('Should not allow invalid password user input', done => {
Copy link

Choose a reason for hiding this comment

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

Replace 'Should·not·allow·invalid·password·user·input' with "Should·not·allow·invalid·password·user·input" prettier/prettier

@@ -2,17 +2,28 @@ import express from 'express';
import bodyParser from 'body-parser';
import swagger from 'swagger-ui-express';
import logger from 'morgan';
import passport from 'passport';
Copy link

Choose a reason for hiding this comment

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

Replace 'passport' with "passport" prettier/prettier

@@ -14,7 +14,7 @@ dotenv.config();
* @returns {Response} object
*/

const getToken = user => {
export const getToken = user => {
Copy link

Choose a reason for hiding this comment

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

Unexpected block statement surrounding arrow body; move the returned value immediately after the => arrow-body-style

const socialRedirect = async (request, response) => {
if (request.user.noEmail) {
return Helper.failResponse(response, 400, {
message: 'user has no email address'
Copy link

Choose a reason for hiding this comment

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

Replace 'user·has·no·email·address' with "user·has·no·email·address" prettier/prettier

where: { email: userEmail },
defaults: {
firstName: names[0] || 'Firstname',
lastName: names[1] || 'Lastname',
Copy link

Choose a reason for hiding this comment

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

Replace 'Lastname' with "Lastname" prettier/prettier

@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from d60b406 to 638f556 Compare July 9, 2019 17:34
const [user] = await User.findOrCreate({
where: { email: userEmail },
defaults: {
firstName: names[0] || 'Firstname',
Copy link

Choose a reason for hiding this comment

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

Replace 'Firstname' with "Firstname" prettier/prettier

return done(null, userWithNoEmail);
}
const userEmail = emails[0].value;
const names = displayName ? displayName.split(' ') : ['', ''];
Copy link

Choose a reason for hiding this comment

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

Replace '·')·:·['',·'' with "·")·:·["",·"" prettier/prettier

import { getToken } from '../helpers/jwt.helper';
import model from '../db/models';
import Helper from '../services/helper';
import { hashPassword } from '../services/auth.service';
Copy link

Choose a reason for hiding this comment

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

Replace '../services/auth.service' with "../services/auth.service" prettier/prettier

@@ -0,0 +1,63 @@
import { getToken } from '../helpers/jwt.helper';
import model from '../db/models';
import Helper from '../services/helper';
Copy link

Choose a reason for hiding this comment

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

Replace '../services/helper' with "../services/helper" prettier/prettier

@@ -0,0 +1,63 @@
import { getToken } from '../helpers/jwt.helper';
import model from '../db/models';
Copy link

Choose a reason for hiding this comment

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

Replace '../db/models' with "../db/models" prettier/prettier

import { Strategy as TwitterStrategy } from 'passport-twitter';
import { Strategy as GoogleStrategy } from 'passport-google-oauth20';

import dotenv from 'dotenv';
Copy link

Choose a reason for hiding this comment

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

Replace 'dotenv' with "dotenv" prettier/prettier

import passport from 'passport';
import { Strategy as FacebookStrategy } from 'passport-facebook';
import { Strategy as TwitterStrategy } from 'passport-twitter';
import { Strategy as GoogleStrategy } from 'passport-google-oauth20';
Copy link

Choose a reason for hiding this comment

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

Replace 'passport-google-oauth20' with "passport-google-oauth20" prettier/prettier

@@ -0,0 +1,58 @@
import passport from 'passport';
import { Strategy as FacebookStrategy } from 'passport-facebook';
import { Strategy as TwitterStrategy } from 'passport-twitter';
Copy link

Choose a reason for hiding this comment

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

Replace 'passport-twitter' with "passport-twitter" prettier/prettier

@@ -0,0 +1,58 @@
import passport from 'passport';
import { Strategy as FacebookStrategy } from 'passport-facebook';
Copy link

Choose a reason for hiding this comment

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

Replace 'passport-facebook' with "passport-facebook" prettier/prettier

@@ -0,0 +1,58 @@
import passport from 'passport';
Copy link

Choose a reason for hiding this comment

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

Replace 'passport' with "passport" prettier/prettier

@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from 638f556 to e5526e3 Compare July 10, 2019 11:57
@@ -1,6 +1,6 @@
import bcrypt from 'bcryptjs';
import crypto from 'crypto';
import getToken from '../helpers/jwt.helper';
import { getToken } from '../helpers/jwt.helper';
Copy link

Choose a reason for hiding this comment

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

Replace '../helpers/jwt.helper' with "../helpers/jwt.helper" prettier/prettier

@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from e5526e3 to 4819c30 Compare July 11, 2019 02:36
@@ -17,7 +17,7 @@ const { User, Follow } = model;
export const getAllUsersService = async () => {
const users = await User.findAll({
attributes: {
exclude: ['password', 'confirmEmailCode']
exclude: ['password', 'confirmEmailCode', 'passwordToken']
Copy link

Choose a reason for hiding this comment

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

Replace 'password',·'confirmEmailCode',·'passwordToken' with "password",·"confirmEmailCode",·"passwordToken" prettier/prettier

'/google',
passport.authenticate('google', { scope: ['email', 'profile'] })
)
.get('/google/callback', passport.authenticate('google'), socialRedirect);
Copy link

Choose a reason for hiding this comment

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

Replace '/google/callback',·passport.authenticate('google' with "/google/callback",·passport.authenticate("google" prettier/prettier

router
.get(
'/google',
passport.authenticate('google', { scope: ['email', 'profile'] })
Copy link

Choose a reason for hiding this comment

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

Replace 'google',·{·scope:·['email',·'profile' with "google",·{·scope:·["email",·"profile" prettier/prettier


router
.get(
'/google',
Copy link

Choose a reason for hiding this comment

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

Replace '/google' with "/google" prettier/prettier

.get('/twitter', passport.authenticate('twitter', { scope: ['email'] }))
.get(
'/twitter/callback',
passport.authenticate('twitter', { session: false }),
Copy link

Choose a reason for hiding this comment

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

Replace 'twitter' with "twitter" prettier/prettier

router
.get(
'/facebook',
passport.authenticate('facebook', {
Copy link

Choose a reason for hiding this comment

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

Replace 'facebook' with "facebook" prettier/prettier


router
.get(
'/facebook',
Copy link

Choose a reason for hiding this comment

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

Replace '/facebook' with "/facebook" prettier/prettier

@@ -0,0 +1,35 @@
import express from 'express';
import passport from 'passport';
import { socialRedirect } from '../../controllers/social.controller';
Copy link

Choose a reason for hiding this comment

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

Replace '../../controllers/social.controller' with "../../controllers/social.controller" prettier/prettier

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

Choose a reason for hiding this comment

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

Replace 'passport' with "passport" prettier/prettier

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

Choose a reason for hiding this comment

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

Replace 'express' with "express" prettier/prettier

>-create facebook/google/twitter app and generate Ids and secret keys
>-setup middleware(passport)that interfaces with social sites
>-create controller function that returns user token after successfull
>-write unit tests
>-add api documentation using swagger
@halimahO halimahO force-pushed the ft-enable-social-login-166816103 branch from 4819c30 to 5e8d6ff Compare July 11, 2019 11:30
@nedemenang nedemenang merged commit 9c8b167 into develop Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants