-
Notifications
You must be signed in to change notification settings - Fork 1
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
#162727467 Enable social login #18
#162727467 Enable social login #18
Conversation
Implement social controller Add services folder, and implement strategy for twitter, facebook, and google Modify migrations, and allowNull for password and signUpType Write test for Social Controller [Delivers #162727467]
Implement social controller Add services folder, and implement strategy for twitter, facebook, and google Modify migrations, and allowNull for password and signUpType Write test for Social Controller Fix merge conflicts [Delivers 162727467]
@@ -0,0 +1,92 @@ | |||
import 'babel-polyfill'; |
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'
@@ -0,0 +1,32 @@ | |||
/* eslint-disable no-underscore-dangle */ | |||
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.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,25 @@ | |||
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.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,174 @@ | |||
/* eslint-disable no-underscore-dangle */ | |||
/* eslint-disable camelcase */ | |||
import models 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.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/routes/socialRouter.js
Outdated
passport.authenticate('twitter', { scope: ['include_email =true'] })); | ||
|
||
socialRouter.get('/twitter/callback', | ||
passport.authenticate('twitter'), SocialController.getToken); |
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 a newline before ')' function-paren-newline
src/routes/socialRouter.js
Outdated
socialRouter.get('/twitter', | ||
passport.authenticate('twitter', { scope: ['include_email =true'] })); | ||
|
||
socialRouter.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.
Expected a newline after '(' function-paren-newline
src/routes/socialRouter.js
Outdated
passport.authenticate('google'), SocialController.getToken); | ||
|
||
socialRouter.get('/twitter', | ||
passport.authenticate('twitter', { scope: ['include_email =true'] })); |
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 a newline before ')' function-paren-newline
src/routes/socialRouter.js
Outdated
socialRouter.get('/google/callback', | ||
passport.authenticate('google'), SocialController.getToken); | ||
|
||
socialRouter.get('/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.
Expected a newline after '(' function-paren-newline
src/routes/socialRouter.js
Outdated
passport.authenticate('google', { scope: ['profile', 'email'] })); | ||
|
||
socialRouter.get('/google/callback', | ||
passport.authenticate('google'), SocialController.getToken); |
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 a newline before ')' function-paren-newline
src/routes/socialRouter.js
Outdated
|
||
socialRouter.get('/facebook/callback', | ||
passport.authenticate('facebook'), SocialController.getToken); | ||
socialRouter.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.
Expected a newline after '(' function-paren-newline
src/routes/socialRouter.js
Outdated
passport.authenticate('facebook', { scope: ['email'] })); | ||
|
||
socialRouter.get('/facebook/callback', | ||
passport.authenticate('facebook'), SocialController.getToken); |
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 a newline before ')' function-paren-newline
src/routes/socialRouter.js
Outdated
socialRouter.get('/facebook', | ||
passport.authenticate('facebook', { scope: ['email'] })); | ||
|
||
socialRouter.get('/facebook/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.
Expected a newline after '(' function-paren-newline
src/routes/socialRouter.js
Outdated
const socialRouter = express.Router(); | ||
|
||
socialRouter.get('/facebook', | ||
passport.authenticate('facebook', { 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.
Expected a newline before ')' function-paren-newline
src/routes/socialRouter.js
Outdated
|
||
const socialRouter = express.Router(); | ||
|
||
socialRouter.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.
Expected a newline after '(' function-paren-newline
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.
Looking good 👍
}); | ||
} | ||
userDetails.newUser = isCreated; | ||
return done(null, userDetails); |
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 are you using a callback? It's required by 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.
yes it is
src/controllers/SocialsController.js
Outdated
const { | ||
displayName, emails, | ||
} = profile; | ||
const { bio } = profile || null; |
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 will crash the app when/if profile is not available and it resolves to null
; You might want to do something like
const bio = profile.bio || null;
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, on it.
src/controllers/SocialsController.js
Outdated
displayName, emails, | ||
} = profile; | ||
const { bio } = profile || null; | ||
const { imgURL } = profile || null; |
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.
Same here
src/controllers/SocialsController.js
Outdated
const { | ||
displayName, emails, | ||
} = profile; | ||
const { bio } = profile || null; |
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.
Same here.
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, on it.
src/controllers/SocialsController.js
Outdated
displayName, emails, | ||
} = profile; | ||
const { bio } = profile || null; | ||
const { imgURL } = profile || null; |
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.
Same here.
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, on it.
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
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.
LGTM
What does this PR do?
Implement Social(twitter, facebook and google) authentication
Description of Task to be completed?
How should this be manually tested?
npm i
-for facebook
localhost:9000/api/v1/auth/facebook
-for twitter
localhost:9000/api/v1/auth/twitter
-for google
localhost:9000/api/v1/auth/google
The URL return the following data
message
andtoken
Any background context you want to provide?
Twitter takes time to supply the consumer secret(about 5hours), and allowNull was set to true for password and userType, because the response coming in does not contain password, and the userType can be edited after the logs in and edit profile
What are the relevant pivotal tracker stories?
162727467
Screenshots (if appropriate)
#### Questions: N/A