debug auth in production
parent
503d6ada8a
commit
d533e07edd
|
@ -12,20 +12,13 @@ var _ = require('lodash'),
|
||||||
nodemailer = require('nodemailer'),
|
nodemailer = require('nodemailer'),
|
||||||
secrets = require('./secrets');
|
secrets = require('./secrets');
|
||||||
|
|
||||||
// Login Required middleware.
|
|
||||||
module.exports = {
|
|
||||||
isAuthenticated: isAuthenticated,
|
|
||||||
isAuthorized: isAuthorized
|
|
||||||
};
|
|
||||||
|
|
||||||
passport.serializeUser(function(user, done) {
|
passport.serializeUser(function(user, done) {
|
||||||
done(null, user.id);
|
done(null, user.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
passport.deserializeUser(function(id, done) {
|
passport.deserializeUser(function(id, done) {
|
||||||
User.findOne({
|
User.findById(id, function(err, user) {
|
||||||
_id: id
|
|
||||||
}, '-password', function(err, user) {
|
|
||||||
done(err, user);
|
done(err, user);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -381,12 +374,16 @@ passport.use(new LinkedInStrategy(secrets.linkedin, function(req, accessToken, r
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function isAuthenticated(req, res, next) {
|
// Login Required middleware.
|
||||||
|
|
||||||
|
exports.isAuthenticated = function(req, res, next) {
|
||||||
if (req.isAuthenticated()) return next();
|
if (req.isAuthenticated()) return next();
|
||||||
res.redirect('/login');
|
res.redirect('/login');
|
||||||
}
|
};
|
||||||
|
|
||||||
function isAuthorized(req, res, next) {
|
// Authorization Required middleware.
|
||||||
|
|
||||||
|
exports.isAuthorized = function(req, res, next) {
|
||||||
var provider = req.path.split('/').slice(-1)[0];
|
var provider = req.path.split('/').slice(-1)[0];
|
||||||
|
|
||||||
if (_.find(req.user.tokens, { kind: provider })) {
|
if (_.find(req.user.tokens, { kind: provider })) {
|
||||||
|
@ -394,4 +391,4 @@ function isAuthorized(req, res, next) {
|
||||||
} else {
|
} else {
|
||||||
res.redirect('/auth/' + provider);
|
res.redirect('/auth/' + provider);
|
||||||
}
|
}
|
||||||
}
|
};
|
|
@ -1,9 +1,10 @@
|
||||||
extends ../layout
|
extends ../layout
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
.jumbotron
|
||||||
.col-sm-8.col-sm-offset-2
|
.col-sm-8.col-sm-offset-2
|
||||||
form(method='POST')
|
form(method='POST')
|
||||||
legend Forgot Password
|
h1 Forgot Password
|
||||||
input(type='hidden', name='_csrf', value=_csrf)
|
input(type='hidden', name='_csrf', value=_csrf)
|
||||||
.form-group
|
.form-group
|
||||||
p Enter your email address below and we will send you password reset instructions.
|
p Enter your email address below and we will send you password reset instructions.
|
||||||
|
|
|
@ -243,11 +243,11 @@ block content
|
||||||
a.btn.btn-lg.btn-block.btn-facebook.btn-link-social(href='/auth/facebook')
|
a.btn.btn-lg.btn-block.btn-facebook.btn-link-social(href='/auth/facebook')
|
||||||
i.fa.fa-facebook
|
i.fa.fa-facebook
|
||||||
| Link Facebook with your account
|
| Link Facebook with your account
|
||||||
//- if (!user.github)
|
- if (!user.github)
|
||||||
// .col-xs-12
|
.col-xs-12
|
||||||
// a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/auth/github')
|
a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/auth/github')
|
||||||
// i.fa.fa-github
|
i.fa.fa-github
|
||||||
// | Link GitHub with your account
|
| Link GitHub with your account
|
||||||
- if (!user.linkedin)
|
- if (!user.linkedin)
|
||||||
.col-xs-12
|
.col-xs-12
|
||||||
a.btn.btn-lg.btn-block.btn-linkedin.btn-link-social(href='/auth/linkedin')
|
a.btn.btn-lg.btn-block.btn-linkedin.btn-link-social(href='/auth/linkedin')
|
||||||
|
|
Loading…
Reference in New Issue