-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
131 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import passport from 'passport'; | ||
import { Strategy as FacebookStrategy } from 'passport-facebook'; | ||
import { Strategy as GoogleStrategy } from 'passport-google-oauth20'; | ||
import configAuth from './socialConfig'; | ||
import SocialAuthController from '../controllers/socialAuth'; | ||
|
||
|
||
// the strategies for getting the user's facebook, twitter and google id | ||
// the strategies for getting the user's facebook and google id | ||
|
||
// pull in our app id and secret from our social config file | ||
passport.use(new FacebookStrategy({ | ||
|
||
clientID: configAuth.facebookAuth.clientID, | ||
clientSecret: configAuth.facebookAuth.clientSecret, | ||
callbackURL: configAuth.facebookAuth.callbackURL, | ||
profileFields: configAuth.facebookAuth.profileFields | ||
clientID: process.env.FACEBOOK_APP_ID, | ||
clientSecret: process.env.FACEBOOK_APP_SECRET, | ||
callbackURL: process.env.FACEBOOK_CALLBACK_URL, | ||
profileURL: 'https://graph.facebook.com/v2.5/me?fields=first_name,last_name,email', | ||
profileFields: ['id', 'emails', 'name', 'photos', 'displayName'] | ||
}, SocialAuthController.passportCallback)); | ||
|
||
// pull in our app id and secret from our social config file | ||
passport.use(new GoogleStrategy({ | ||
|
||
clientID: configAuth.googleAuth.clientID, | ||
clientSecret: configAuth.googleAuth.clientSecret, | ||
callbackURL: configAuth.googleAuth.callbackURL, | ||
clientID: process.env.GOOGLE_APP_ID, | ||
clientSecret: process.env.GOOGLE_APP_SECRET, | ||
callbackURL: process.env.GOOGLE_CALLBACK_URL, | ||
proxy: true | ||
}, SocialAuthController.passportCallback)); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import chai, { expect } from 'chai'; | ||
import chaiHttp from 'chai-http'; | ||
import nock from 'nock'; | ||
import app from '../../..'; | ||
|
||
chai.use(chaiHttp); | ||
|
||
// This is a test to show that the external services was called | ||
describe('Signs up user with their Google account', () => { | ||
before(() => { | ||
nock('https://accounts.google.com') | ||
.filteringPath(() => '/') | ||
.get('/') | ||
.reply(200, { | ||
message: 'You are logged in', | ||
user: { | ||
id: 10, | ||
role: 'user', | ||
firstName: 'Mo\'rin', | ||
lastName: 'd\'okla', | ||
username: 'corn', | ||
email: 'job.adelia.com', | ||
image: 'image.png', | ||
token: 'token' | ||
}, | ||
status: 'success' | ||
}); | ||
|
||
nock('https://www.facebook.com') | ||
.filteringPath(() => '/') | ||
.get('/') | ||
.reply(200, { | ||
message: 'You are logged in', | ||
user: { | ||
id: 10, | ||
role: 'user', | ||
firstName: 'Mo\'rin', | ||
lastName: 'd\'okla', | ||
username: 'corn', | ||
email: 'job.adelia.com', | ||
image: 'image.png', | ||
token: 'token' | ||
}, | ||
status: 'success' | ||
}); | ||
}); | ||
|
||
it('Authenticates with google', (done) => { | ||
chai.request(app) | ||
.get('/api/auth/google') | ||
.end((err, res) => { | ||
expect(res.body.message).to.be.equal('You are logged in'); | ||
expect(res.body.status).to.be.equal('success'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Authenticates with facebook', (done) => { | ||
chai.request(app) | ||
.get('/api/auth/facebook') | ||
.end((err, res) => { | ||
expect(res.body.message).to.be.equal('You are logged in'); | ||
expect(res.body.status).to.be.equal('success'); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters