Skip to content

Commit

Permalink
fix issue #5 - if no email permission
Browse files Browse the repository at this point in the history
  • Loading branch information
mAzurkovic committed Jan 21, 2018
1 parent 134a9f6 commit f56122a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
config/auth.js
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ app.use(passport.session()); // persistent login sessions
app.use(flash()); // use connect-flash for flash messages stored in session

mongoose.Promise = global.Promise;
mongoose.connect('mongodb://mattias:[email protected]:33597/bandomap');
mongoose.connect('mongodb://localhost:27017/BandoMap');

// uncomment after placing your favicon in /public
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
Expand Down Expand Up @@ -81,7 +81,7 @@ function getCoords(address) {

// in development, make sure the port is set to 5000
// for production, set port to 3000
app.listen(3000, function () {
app.listen(5000, function () {
console.log('Example app listening on port !');
});

Expand Down
2 changes: 1 addition & 1 deletion config/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
'facebookAuth' : {
'clientID' : '137450936923238', // your App ID
'clientSecret' : '95d4af852e2d15d899c80f1a4ef72f1e', // your App Secret
'callbackURL' : 'https://bandomap.com/auth/facebook/callback',
'callbackURL' : 'http://localhost:5000/auth/facebook/callback',//'https://bandomap.com/auth/facebook/callback',
'profileURL' : 'https://graph.facebook.com/v2.5/me?fields=first_name,last_name,email',
'profileFields' : ['id', 'email', 'name'] // For requesting permissions from Facebook API
}
Expand Down
6 changes: 5 additions & 1 deletion config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ module.exports = function(passport) {
newUser.facebook.id = profile.id; // set the users facebook id
newUser.facebook.token = token; // we will save the token that facebook provides to the user
newUser.facebook.name = profile.name.givenName + ' ' + profile.name.familyName; // look at the passport user profile to see how names are returned
newUser.facebook.email = profile.emails[0].value; // facebook can return multiple emails so we'll take the first
if (typeof profile.emails == 'undefined') {
newUser.facebook.email = "No email provided."; // some users don't allow email from facebook
} else {
newUser.facebook.email = profile.emails[0].value; // facebook can return multiple emails so we'll take the first
}

// save our user to the database
newUser.save(function(err) {
Expand Down

0 comments on commit f56122a

Please sign in to comment.