Skip to content

Commit

Permalink
Merge pull request #59 from andela/bg-oauth-links-167737978
Browse files Browse the repository at this point in the history
#167737978 Hotfix for the O Auth
  • Loading branch information
codexempire committed Aug 7, 2019
2 parents c12cf9f + e82483e commit 7e53e32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/helpers/passport/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import passport from 'passport';
import FacebookStrategy from 'passport-facebook';
import dotenv from 'dotenv';
import { callback, respondCallback } from './callback';
import hostUrl from './hostUrl';

dotenv.config();

Expand All @@ -10,7 +11,7 @@ passport.use(
{
clientID: process.env.fbk_id,
clientSecret: process.env.fbk_secret,
callbackURL: 'http://localhost:3000/auth/facebook/callback',
callbackURL: `${hostUrl}auth/facebook/callback`,
profileFields: ['id', 'displayName', 'photos', 'emails', 'name'],
enableProof: false
},
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/passport/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import passport from 'passport';
import dotenv from 'dotenv';
import GitHubStrategy from 'passport-github2';
import { callback, respondCallback } from './callback';
import hostUrl from './hostUrl';

dotenv.config();

Expand All @@ -10,7 +11,7 @@ passport.use(
{
clientID: process.env.github_clientID,
clientSecret: process.env.github_clientSecret,
callbackURL: 'http://localhost:3000/auth/github/callback',
callbackURL: `${hostUrl}auth/github/callback`,
scope: 'user:email'
},
callback,
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/passport/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import passport from 'passport';
import GoogleStrategy from 'passport-google-oauth20';
import dotenv from 'dotenv';
import { callback, respondCallback } from './callback';
import hostUrl from './hostUrl';

dotenv.config();

passport.use(
new GoogleStrategy(
{
callbackURL: '/auth/google/redirect',
callbackURL: `${hostUrl}auth/google/redirect`,
clientID: process.env.google_clientID,
clientSecret: process.env.google_clientSecret
},
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/passport/hostUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
let hostUrl;

if (process.env.NODE_ENV === 'production') {
hostUrl = process.env.BASE_URL;
} else {
hostUrl = process.env.LOCAL_URL;
}
export default hostUrl;

0 comments on commit 7e53e32

Please sign in to comment.