-
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
#166240994 Enable social login #26
Conversation
test/auth.js
Outdated
import server from '../src/index'; | ||
|
||
const { expect } = chai; | ||
chai.use(chaiHttp); | ||
|
||
const authenticatedUser = request.agent(server); |
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.
'authenticatedUser' is assigned a value but never used no-unused-vars
if (currentUser) { | ||
console.log('this is not a new user'); | ||
console.log(currentUser); | ||
console.log(currentUser.length); |
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
}).then((currentUser) => { | ||
if (currentUser) { | ||
console.log('this is not a new user'); | ||
console.log(currentUser); |
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
}, | ||
}).then((currentUser) => { | ||
if (currentUser) { | ||
console.log('this is not a new 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 console statement no-console
id, displayName, provider | ||
} = req.user; | ||
console.log('hey'); | ||
console.log(req.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 console statement no-console
}, | ||
), | ||
); | ||
passport.use( |
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 newline after '(' function-paren-newline
src/config/passportSetup.js
Outdated
done(null, 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.
Unexpected newline before ')' function-paren-newline
src/config/passportSetup.js
Outdated
}, | ||
), | ||
); | ||
passport.use( |
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 newline after '(' function-paren-newline
src/config/passportSetup.js
Outdated
|
||
dotenv.config(); | ||
|
||
passport.use( |
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 newline after '(' function-paren-newline
3b28c8a
to
c1bff32
Compare
test/auth.test.js
Outdated
@@ -4,16 +4,14 @@ import dotenv from 'dotenv'; | |||
import server from '../src/index'; | |||
import db from '../src/sequelize/models'; | |||
import tokenHelper from '../src/helpers/Token.helper'; | |||
|
|||
import socialController from '../src/middleware/socialAccountExists'; |
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.
'socialController' is defined but never used no-unused-vars
const userExists = { | ||
async google(req, res, next) { | ||
const { emails, displayName } = req.user; | ||
console.log(emails[0].value); |
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
src/api/routes/authRouter.js
Outdated
authRouter.get('/login/google/redirect', passport.authenticate('google', { session: false }), google, socialLogin.googleLogin); | ||
|
||
// routes for facebook | ||
authRouter.get('/login/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.
A space is required after ',' comma-spacing
src/api/controllers/socialLogin.js
Outdated
verified: req.user.emails[0].verified, | ||
socialId: req.user.id, | ||
}); | ||
//console.log(newUser.dataValues); |
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 exception block, space or tab after '//' in comment spaced-comment
src/api/controllers/socialLogin.js
Outdated
|
||
const userInfo = { | ||
async googleLogin(req, res) { | ||
console.log(req.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 console statement no-console
c1bff32
to
9ad5790
Compare
src/config/passportSetup.js
Outdated
profileFields: ['id', 'displayName', 'photos', 'email'], | ||
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
src/config/passportSetup.js
Outdated
callbackURL: '/api/auth/login/google/redirect', | ||
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
a05b043
to
d53be91
Compare
src/config/passportSetup.js
Outdated
profileFields: ['id', 'displayName', 'photos', 'email'], | ||
}, (accessToken, refreshToken, profile, done) => { done(null, profile); }, | ||
),); | ||
passport.use(new TwitterTokenStrategy( |
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 newline after '(' function-paren-newline
src/config/passportSetup.js
Outdated
callbackURL: '/api/auth/login/facebook/redirect', | ||
profileFields: ['id', 'displayName', 'photos', 'email'], | ||
}, (accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
Unexpected newline before ')' function-paren-newline
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, profile); }, | ||
),); | ||
passport.use(new FacebookStrategy( |
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 newline after '(' function-paren-newline
d53be91
to
0092997
Compare
src/config/passportSetup.js
Outdated
clientSecret: process.env.FCBK_APP_SECRET, | ||
callbackURL: '/api/auth/login/facebook/redirect', | ||
profileFields: ['id', 'displayName', 'photos', 'email'] | ||
}, (accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
src/config/passportSetup.js
Outdated
clientSecret: process.env.GOOGLE_SECRET, | ||
includeEmail: true, | ||
callbackURL: '/api/auth/login/google/redirect' | ||
}, (accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
0092997
to
52f33f3
Compare
src/config/passportSetup.js
Outdated
consumerSecret: process.env.TWITTER_APP_SECRET, | ||
callbackURL: 'http://localhost:3001/api/auth/login/twitter/redirect' | ||
}, | ||
(token, tokenSecret, profile, done) => { done(null, 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.
Expected a newline before ')' function-paren-newline
src/config/passportSetup.js
Outdated
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, profile); },),); | ||
|
||
passport.use(new TwitterTokenStrategy({ |
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/config/passportSetup.js
Outdated
callbackURL: '/api/auth/login/facebook/redirect', | ||
profileFields: ['id', 'displayName', 'photos', 'email'] | ||
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
Expected a newline before ')' function-paren-newline
src/config/passportSetup.js
Outdated
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, profile); },),); | ||
|
||
passport.use(new FacebookStrategy({ |
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/config/passportSetup.js
Outdated
includeEmail: true, | ||
callbackURL: '/api/auth/login/google/redirect' | ||
}, | ||
(accessToken, refreshToken, profile, done) => { done(null, 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.
A space is required after ',' comma-spacing
Expected a newline before ')' function-paren-newline
src/config/passportSetup.js
Outdated
|
||
dotenv.config(); | ||
|
||
passport.use(new GoogleStrategy({ |
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
342afe8
to
762233e
Compare
src/api/routes/authRouter.js
Outdated
// callback route for twitter to redirect to | ||
|
||
authRouter.get('/login/twitter/redirect', passport.authenticate('twitter', { session: false }), | ||
twitter, socialLogin.twitterLogin); |
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/api/routes/authRouter.js
Outdated
|
||
// callback route for twitter to redirect to | ||
|
||
authRouter.get('/login/twitter/redirect', 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.
Expected a newline after '(' function-paren-newline
src/api/routes/authRouter.js
Outdated
// callback route for facebook to redirect to | ||
|
||
authRouter.get('/login/facebook/redirect', passport.authenticate('facebook', { session: false }), | ||
google, socialLogin.facebookLogin); |
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/api/routes/authRouter.js
Outdated
|
||
// callback route for facebook to redirect to | ||
|
||
authRouter.get('/login/facebook/redirect', passport.authenticate('facebook', { 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.
Expected a newline after '(' function-paren-newline
src/api/routes/authRouter.js
Outdated
// callback route for google to redirect to | ||
|
||
authRouter.get('/login/google/redirect', passport.authenticate('google', { session: false }), | ||
google, socialLogin.googleLogin); |
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/api/routes/authRouter.js
Outdated
|
||
// callback route for google to redirect to | ||
|
||
authRouter.get('/login/google/redirect', passport.authenticate('google', { 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.
Expected a newline after '(' function-paren-newline
762233e
to
ac21763
Compare
ac21763
to
3f46d6e
Compare
src/config/passportSetup.js
Outdated
}, (accessToken, refreshToken, profile, done) => { | ||
done(null, 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.
A space is required after ',' comma-spacing
Unexpected newline before ')' function-paren-newline
1b57b89
to
c139fcd
Compare
src/config/passportSetup.js
Outdated
}, | ||
(token, tokenSecret, profile, done) => { | ||
done(null, 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.
Expected a newline before ')' function-paren-newline
src/config/passportSetup.js
Outdated
}, | ||
(accessToken, refreshToken, profile, done) => { | ||
done(null, 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.
A space is required after ',' comma-spacing
Expected a newline before ')' function-paren-newline
src/config/passportSetup.js
Outdated
}, | ||
(accessToken, refreshToken, profile, done) => { | ||
done(null, 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.
A space is required after ',' comma-spacing
Expected a newline before ')' function-paren-newline
c139fcd
to
00fa044
Compare
cb5bf95
to
e2e39ba
Compare
b326f5a
to
451219f
Compare
package.json
Outdated
"handlebars": "^4.1.2", | ||
"install": "^0.12.2", |
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.
Remove unused packages.
package.json
Outdated
@@ -37,7 +39,11 @@ | |||
"morgan": "^1.9.1", | |||
"nodemailer": "^6.2.1", | |||
"passport": "^0.4.0", | |||
"passport-auth0": "^1.1.0", |
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.
Remove this Package.
src/api/controllers/socialLogin.js
Outdated
if (newUser) { | ||
const { | ||
id, firstName, lastName, email, provider | ||
} = newUser.dataValues; |
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.
const {
dataValues: {id, firstName, lastName, email, provider}
} = newUser;
src/config/passportSetup.js
Outdated
{ | ||
consumerKey: process.env.TWITTER_ID, | ||
consumerSecret: process.env.TWITTER_APP_SECRET, | ||
callbackURL: 'http://localhost:3001/api/auth/login/twitter/redirect' |
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.
Remove the hardcoded base_url.
${}
17867be
to
9cb491e
Compare
9cb491e
to
5f8af5a
Compare
What does this PR do?
Enables social login.
Description of Task to be completed?
Allow users to login with their pre-existing social media accounts
How should this be manually tested?
Clone the repo, cd into it and RUN yarn install to install all the dependencies, then RUN yarn dev to start the server.
http://localhost:3001/api/auth/login/facebook
for Facebookhttp://localhost:3001/api/auth/login/google
for Googlehttp://localhost:3001/api/auth/login/twitter
for TwitterWhat are the relevant pivotal tracker stories?
#166240994