Skip to content

Commit

Permalink
Merge pull request #71 from andela/bg-fix-facebook-auth-171406524
Browse files Browse the repository at this point in the history
#171406524 Fix facebook authentication
  • Loading branch information
bdushimi committed Feb 21, 2020
2 parents 4b51c64 + de8a078 commit 1f4cd28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ passport.use(new GoogleStrategy({
passport.use(new FacebookStrategy({
clientID: process.env.FACEBOOK_APP_ID,
clientSecret: process.env.FACEBOOK_APP_SECRET,
callbackURL: '/api/auth/facebook/redirect',
callbackURL: `${process.env.API_URL}/api/auth/facebook/redirect`,
scope: ['public_profile', 'email'],
profileFields: ['id', 'email', 'name']
profileFields: ['id', 'email', 'name', 'photos']
}, facebookAuthMiddleware));
1 change: 1 addition & 0 deletions src/middlewares/facebook-auth.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default async (accessToken, refreshToken, profile, done) => {
lastName: facebookProfile.last_name,
email: facebookProfile.email,
password: BcryptService.hashPassword(Math.random().toString(36)),
profilePicture: facebookProfile.picture.data.url,
isVerified: true
};
const { dataValues } = await UserService.addUser(userdata);
Expand Down
1 change: 1 addition & 0 deletions src/middlewares/google-auth.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default async (accessToken, refreshToken, profile, done) => {
lastName: googleProfile.family_name,
email: googleProfile.email,
password: BcryptService.hashPassword(Math.random().toString(36)),
profilePicture: googleProfile.picture,
isVerified: true
};
const { dataValues } = await UserService.addUser(userdata);
Expand Down
7 changes: 6 additions & 1 deletion src/tests/fixtures/users.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,12 @@ export const facebookProfile = {
_json: {
first_ame: 'userfirstname',
last_name: 'userlastname',
email: 'facebookuser@gmail.com'
email: 'facebookuser@gmail.com',
picture: {
data: {
url: 'ufhuierhfierhfiuhreiufheiru'
}
}
}
};
export const OAuthTokens = {
Expand Down

0 comments on commit 1f4cd28

Please sign in to comment.