-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
f7801ec
commit c7936ce
Showing
5 changed files
with
107 additions
and
47 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
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,39 +1,57 @@ | ||
exports.setup = function (User, config) { | ||
var passport = require('passport'); | ||
var OAuth1Strategy = require('passport-oauth1').Strategy; | ||
|
||
var passport = require('passport') | ||
, OpenIDStrategy = require('passport-openid').Strategy; | ||
|
||
passport.use(new OAuth1Strategy({ | ||
|
||
userAuthorizationURL: config.carre.userAuthorizationURL||'http://google.com', | ||
requestTokenURL: config.carre.requestTokenURL||'http://google.com', | ||
accessTokenURL: config.carre.accessTokenURL||'http://google.com', | ||
consumerKey: config.carre.clientID, | ||
consumerSecret: config.carre.clientSecret, | ||
callbackURL: config.carre.callbackURL | ||
passport.use(new OpenIDStrategy({ | ||
providerURL:'http://localhost:3000', | ||
returnURL: 'http://edu.carre-project.eu/auth/carre/callback', | ||
realm: 'http://edu.carre-project.eu/', | ||
profile: true | ||
}, | ||
function(token, tokenSecret, profile, done) { | ||
User.findOne({ | ||
'carre.id_str': profile.id | ||
}, function(err, user) { | ||
if (err) { | ||
return done(err); | ||
} | ||
if (!user) { | ||
user = new User({ | ||
name: profile.displayName, | ||
username: profile.username, | ||
role: 'user', | ||
provider: 'carre', | ||
carre: profile._json | ||
}); | ||
user.save(function(err) { | ||
if (err) return done(err); | ||
return done(err, user); | ||
}); | ||
} else { | ||
return done(err, user); | ||
} | ||
function(identifier, profile, done) { | ||
User.findOrCreate({ openId: identifier }, function(err, user) { | ||
done(err, user); | ||
}); | ||
} | ||
)); | ||
} | ||
)); | ||
|
||
|
||
// passport.use(new OAuth1Strategy({ | ||
|
||
// userAuthorizationURL: config.carre.userAuthorizationURL||'http://google.com', | ||
// requestTokenURL: config.carre.requestTokenURL||'http://google.com', | ||
// accessTokenURL: config.carre.accessTokenURL||'http://google.com', | ||
// consumerKey: config.carre.clientID, | ||
// consumerSecret: config.carre.clientSecret, | ||
// callbackURL: config.carre.callbackURL | ||
// }, | ||
// function(token, tokenSecret, profile, done) { | ||
// User.findOne({ | ||
// 'carre.id_str': profile.id | ||
// }, function(err, user) { | ||
// if (err) { | ||
// return done(err); | ||
// } | ||
// if (!user) { | ||
// user = new User({ | ||
// name: profile.displayName, | ||
// username: profile.username, | ||
// role: 'user', | ||
// provider: 'carre', | ||
// carre: profile._json | ||
// }); | ||
// user.save(function(err) { | ||
// if (err) return done(err); | ||
// return done(err, user); | ||
// }); | ||
// } else { | ||
// return done(err, user); | ||
// } | ||
// }); | ||
// } | ||
// )); | ||
|
||
|
||
|
||
}; |