Tumblr OAuth strategy
This commit is contained in:
@ -93,17 +93,26 @@ passport.use(new GoogleStrategy(config.google, function(accessToken, refreshToke
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Simple route middleware to ensure user is authenticated. Otherwise send to login page.
|
passport.use('tumblr', new OAuthStrategy({
|
||||||
exports.ensureAuthenticated = function ensureAuthenticated(req, res, next) {
|
requestTokenURL: 'http://www.tumblr.com/oauth/request_token',
|
||||||
if (req.isAuthenticated()) {
|
accessTokenURL: 'http://www.tumblr.com/oauth/access_token',
|
||||||
return next();
|
userAuthorizationURL: 'http://www.tumblr.com/oauth/authorize',
|
||||||
|
consumerKey: config.tumblr.consumerKey,
|
||||||
|
consumerSecret: config.tumblr.consumerSecret,
|
||||||
|
callbackURL: config.tumblr.callbackURL
|
||||||
|
},
|
||||||
|
function(token, tokenSecret, profile, done) {
|
||||||
|
User.findOne({ tumblr: profile.id }, function(err, existingUser) {
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
exports.ensureAuthenticated = function ensureAuthenticated(req, res, next) {
|
||||||
|
if (req.isAuthenticated()) return next();
|
||||||
res.redirect('/login');
|
res.redirect('/login');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Check for admin middleware, this is unrelated to passport.js
|
|
||||||
// You can delete this if you use different method to check for admins or don't need admins
|
|
||||||
exports.ensureAdmin = function ensureAdmin(req, res, next) {
|
exports.ensureAdmin = function ensureAdmin(req, res, next) {
|
||||||
return function(req, res, next) {
|
return function(req, res, next) {
|
||||||
console.log(req.user);
|
console.log(req.user);
|
||||||
|
Reference in New Issue
Block a user