-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
src/tests/controller/auth.spec.js
Outdated
it('Should return an error 400 when getting all users', () => { | ||
const request = {}; | ||
const response = new Response(); | ||
sinon.stub(response, 'status').returnsThis(); |
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.
Replace 'status'
with "status"
prettier/prettier
src/tests/controller/auth.spec.js
Outdated
@@ -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', () => { |
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.
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' |
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.
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'); |
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.
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'); |
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.
Replace 'data'
with "data"
prettier/prettier
}); | ||
}); | ||
|
||
it('Should not allow invalid password user input', done => { |
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.
Replace 'Should·not·allow·invalid·password·user·input'
with "Should·not·allow·invalid·password·user·input"
prettier/prettier
src/tests/controller/auth.spec.js
Outdated
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' |
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.
Replace 'Last·name·must·be·only·alphabetical·chars'
with "Last·name·must·be·only·alphabetical·chars"
prettier/prettier
src/tests/controller/auth.spec.js
Outdated
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'); |
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.
Replace 'fail'
with "fail"
prettier/prettier
src/tests/controller/auth.spec.js
Outdated
.end((error, response) => { | ||
expect(response.status).to.equal(400); | ||
expect(response.body).to.have.property('status'); | ||
expect(response.body).to.have.property('data'); |
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.
Replace 'data'
with "data"
prettier/prettier
src/tests/controller/auth.spec.js
Outdated
}) | ||
.end((error, response) => { | ||
expect(response.status).to.equal(400); | ||
expect(response.body).to.have.property('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.
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'; |
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.
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'; |
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.
Replace './controller/social.spec'
with "./controller/social.spec"
prettier/prettier
const tokenMock = 'fake.token'; | ||
|
||
sinon.spy(Helper, 'successResponse'); | ||
sinon.stub(jwtHelper, 'getToken').returns(tokenMock); |
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.
Replace 'getToken'
with "getToken"
prettier/prettier
|
||
const tokenMock = 'fake.token'; | ||
|
||
sinon.spy(Helper, 'successResponse'); |
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.
Replace 'successResponse'
with "successResponse"
prettier/prettier
roleType: 'guest' | ||
}; | ||
|
||
const tokenMock = 'fake.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.
Replace 'fake.token'
with "fake.token"
prettier/prettier
json() {} | ||
}; | ||
|
||
it('responds with 400 for user with no email', async () => { |
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.
Replace 'responds·with·400·for·user·with·no·email'
with "responds·with·400·for·user·with·no·email"
prettier/prettier
}); | ||
}); | ||
|
||
describe('socialRedirect', () => { |
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.
Replace 'socialRedirect'
with "socialRedirect"
prettier/prettier
} | ||
}; | ||
|
||
sinon.stub(User, 'findOrCreate').returns([userMock]); |
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.
Replace 'findOrCreate'
with "findOrCreate"
prettier/prettier
profileMock.emails = [{ value: 'johndoe@mail.com' }]; | ||
const userMock = { | ||
dataValues: { | ||
email: 'johndoe@mail.com' |
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.
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' }]; |
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.
Replace 'johndoe@mail.com'
with "johndoe@mail.com"
prettier/prettier
expect(done).calledOnceWith(null, { noEmail: true }); | ||
}); | ||
|
||
it('successfully authenticate and get/create user', async () => { |
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.
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 () => { |
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.
Replace 'responds·with·no·email'
with "responds·with·no·email"
prettier/prettier
id: '122', | ||
displayName: 'john doe', | ||
provider: 'AH', | ||
photos: [{ value: 'img.io' }] |
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.
Replace 'img.io'
with "img.io"
prettier/prettier
const profileMock = { | ||
id: '122', | ||
displayName: 'john doe', | ||
provider: 'AH', |
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.
Replace 'AH'
with "AH"
prettier/prettier
describe('socialCallback', () => { | ||
const profileMock = { | ||
id: '122', | ||
displayName: 'john doe', |
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.
Replace 'john·doe'
with "john·doe"
prettier/prettier
import { | ||
socialCallback, | ||
socialRedirect | ||
} from '../../controllers/social.controller'; |
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.
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'; |
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.
Replace 'chai'
with "chai"
prettier/prettier
@@ -0,0 +1,87 @@ | |||
import sinon from 'sinon'; | |||
import sinonChai from 'sinon-chai'; |
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.
Replace 'sinon-chai'
with "sinon-chai"
prettier/prettier
@@ -0,0 +1,87 @@ | |||
import sinon from 'sinon'; |
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.
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'; |
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.
Replace '../helpers/jwt.helper'
with "../helpers/jwt.helper"
prettier/prettier
7529bd4
to
5b8d24f
Compare
@@ -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'; |
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.
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); |
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.
Replace '/google/callback',·passport.authenticate('google'
with "/google/callback",·passport.authenticate("google"
prettier/prettier
src/routes/v1/social.route.js
Outdated
); | ||
|
||
router | ||
.get('/google', passport.authenticate('google', { scope: ['email'] })) |
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.
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 }), |
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.
Replace 'twitter'
with "twitter"
prettier/prettier
router | ||
.get('/twitter', passport.authenticate('twitter', { scope: ['email'] })) | ||
.get( | ||
'/twitter/callback', |
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.
Replace '/twitter/callback'
with "/twitter/callback"
prettier/prettier
@@ -0,0 +1,27 @@ | |||
import express from 'express'; |
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.
Replace 'express'
with "express"
prettier/prettier
src/routes/v1/index.js
Outdated
|
||
export default app => { | ||
app.use('/api/v1/auth/', socialAuth); |
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.
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'; |
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.
Replace './social.route'
with "./social.route"
prettier/prettier
import swaggerConfig from '../swagger.json'; | ||
import Routes from './routes/v1'; | ||
import './config/passportStrategies'; |
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.
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'; |
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.
Replace 'express-session'
with "express-session"
prettier/prettier
5b8d24f
to
d1ccde4
Compare
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' |
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.
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'); |
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.
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'); |
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.
Replace 'data'
with "data"
prettier/prettier
}) | ||
.end((error, response) => { | ||
expect(response.status).to.equal(400); | ||
expect(response.body).to.have.property('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.
Replace 'status'
with "status"
prettier/prettier
.send({ | ||
email: 'sandy@gmail.com', | ||
password: 'samsss', | ||
firstName: 'gfhshs', |
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.
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'); |
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.
Replace 'data'
with "data"
prettier/prettier
}) | ||
.end((error, response) => { | ||
expect(response.status).to.equal(400); | ||
expect(response.body).to.have.property('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.
Replace 'status'
with "status"
prettier/prettier
email: 'sandy@gmail.com', | ||
password: 'samsss', | ||
firstName: 23, | ||
lastName: 'ghghghg' |
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.
Replace 'ghghghg'
with "ghghghg"
prettier/prettier
.post('/api/v1/users/signup') | ||
.send({ | ||
email: 'sandy@gmail.com', | ||
password: 'samsss', |
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.
Replace 'samsss'
with "samsss"
prettier/prettier
.request(app) | ||
.post('/api/v1/users/signup') | ||
.send({ | ||
email: 'sandy@gmail.com', |
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.
Replace 'sandy@gmail.com'
with "sandy@gmail.com"
prettier/prettier
d1ccde4
to
d60b406
Compare
it('Should not allow duplicated user register', done => { | ||
chai | ||
.request(app) | ||
.post('/api/v1/users/signup') |
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.
Replace '/api/v1/users/signup'
with "/api/v1/users/signup"
prettier/prettier
}); | ||
}); | ||
|
||
it('Should not allow duplicated user register', done => { |
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.
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' |
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.
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'); |
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.
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'); |
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.
Replace 'data'
with "data"
prettier/prettier
@@ -178,6 +178,72 @@ describe('Auth API endpoints', () => { | |||
}); | |||
}); | |||
|
|||
it('Should not allow invalid password user input', done => { |
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.
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'; |
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.
Replace 'passport'
with "passport"
prettier/prettier
@@ -14,7 +14,7 @@ dotenv.config(); | |||
* @returns {Response} object | |||
*/ | |||
|
|||
const getToken = user => { | |||
export const getToken = user => { |
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 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' |
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.
Replace 'user·has·no·email·address'
with "user·has·no·email·address"
prettier/prettier
src/controllers/social.controller.js
Outdated
where: { email: userEmail }, | ||
defaults: { | ||
firstName: names[0] || 'Firstname', | ||
lastName: names[1] || 'Lastname', |
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.
Replace 'Lastname'
with "Lastname"
prettier/prettier
d60b406
to
638f556
Compare
src/controllers/social.controller.js
Outdated
const [user] = await User.findOrCreate({ | ||
where: { email: userEmail }, | ||
defaults: { | ||
firstName: names[0] || 'Firstname', |
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.
Replace 'Firstname'
with "Firstname"
prettier/prettier
return done(null, userWithNoEmail); | ||
} | ||
const userEmail = emails[0].value; | ||
const names = displayName ? displayName.split(' ') : ['', '']; |
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.
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'; |
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.
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'; |
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.
Replace '../services/helper'
with "../services/helper"
prettier/prettier
@@ -0,0 +1,63 @@ | |||
import { getToken } from '../helpers/jwt.helper'; | |||
import model from '../db/models'; |
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.
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'; |
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.
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'; |
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.
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'; |
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.
Replace 'passport-twitter'
with "passport-twitter"
prettier/prettier
@@ -0,0 +1,58 @@ | |||
import passport from 'passport'; | |||
import { Strategy as FacebookStrategy } from 'passport-facebook'; |
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.
Replace 'passport-facebook'
with "passport-facebook"
prettier/prettier
@@ -0,0 +1,58 @@ | |||
import passport from 'passport'; |
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.
Replace 'passport'
with "passport"
prettier/prettier
638f556
to
e5526e3
Compare
@@ -1,6 +1,6 @@ | |||
import bcrypt from 'bcryptjs'; | |||
import crypto from 'crypto'; | |||
import getToken from '../helpers/jwt.helper'; | |||
import { getToken } from '../helpers/jwt.helper'; |
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.
Replace '../helpers/jwt.helper'
with "../helpers/jwt.helper"
prettier/prettier
e5526e3
to
4819c30
Compare
@@ -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'] |
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.
Replace 'password',·'confirmEmailCode',·'passwordToken'
with "password",·"confirmEmailCode",·"passwordToken"
prettier/prettier
'/google', | ||
passport.authenticate('google', { scope: ['email', 'profile'] }) | ||
) | ||
.get('/google/callback', passport.authenticate('google'), socialRedirect); |
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.
Replace '/google/callback',·passport.authenticate('google'
with "/google/callback",·passport.authenticate("google"
prettier/prettier
router | ||
.get( | ||
'/google', | ||
passport.authenticate('google', { scope: ['email', 'profile'] }) |
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.
Replace 'google',·{·scope:·['email',·'profile'
with "google",·{·scope:·["email",·"profile"
prettier/prettier
|
||
router | ||
.get( | ||
'/google', |
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.
Replace '/google'
with "/google"
prettier/prettier
.get('/twitter', passport.authenticate('twitter', { scope: ['email'] })) | ||
.get( | ||
'/twitter/callback', | ||
passport.authenticate('twitter', { session: false }), |
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.
Replace 'twitter'
with "twitter"
prettier/prettier
router | ||
.get( | ||
'/facebook', | ||
passport.authenticate('facebook', { |
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.
Replace 'facebook'
with "facebook"
prettier/prettier
|
||
router | ||
.get( | ||
'/facebook', |
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.
Replace '/facebook'
with "/facebook"
prettier/prettier
@@ -0,0 +1,35 @@ | |||
import express from 'express'; | |||
import passport from 'passport'; | |||
import { socialRedirect } from '../../controllers/social.controller'; |
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.
Replace '../../controllers/social.controller'
with "../../controllers/social.controller"
prettier/prettier
@@ -0,0 +1,35 @@ | |||
import express from 'express'; | |||
import passport from 'passport'; |
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.
Replace 'passport'
with "passport"
prettier/prettier
@@ -0,0 +1,35 @@ | |||
import express from 'express'; |
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.
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
4819c30
to
5e8d6ff
Compare
What does this PR do?
Enable facebook login/signup
Description of Task to be completed?
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