debug auth in production
parent
503d6ada8a
commit
d533e07edd
|
@ -12,20 +12,13 @@ var _ = require('lodash'),
|
|||
nodemailer = require('nodemailer'),
|
||||
secrets = require('./secrets');
|
||||
|
||||
// Login Required middleware.
|
||||
module.exports = {
|
||||
isAuthenticated: isAuthenticated,
|
||||
isAuthorized: isAuthorized
|
||||
};
|
||||
|
||||
passport.serializeUser(function(user, done) {
|
||||
done(null, user.id);
|
||||
});
|
||||
|
||||
passport.deserializeUser(function(id, done) {
|
||||
User.findOne({
|
||||
_id: id
|
||||
}, '-password', function(err, user) {
|
||||
User.findById(id, function(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();
|
||||
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];
|
||||
|
||||
if (_.find(req.user.tokens, { kind: provider })) {
|
||||
|
@ -394,4 +391,4 @@ function isAuthorized(req, res, next) {
|
|||
} else {
|
||||
res.redirect('/auth/' + provider);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,15 +1,16 @@
|
|||
extends ../layout
|
||||
|
||||
block content
|
||||
.col-sm-8.col-sm-offset-2
|
||||
form(method='POST')
|
||||
legend Forgot Password
|
||||
input(type='hidden', name='_csrf', value=_csrf)
|
||||
.form-group
|
||||
p Enter your email address below and we will send you password reset instructions.
|
||||
label.control-label(for='email') Email
|
||||
input.form-control(type='email', name='email', id='email', placeholder='Email', autofocus=true)
|
||||
.form-group
|
||||
button.btn.btn-primary(type='submit')
|
||||
i.fa.fa-key
|
||||
| Reset Password
|
||||
.jumbotron
|
||||
.col-sm-8.col-sm-offset-2
|
||||
form(method='POST')
|
||||
h1 Forgot Password
|
||||
input(type='hidden', name='_csrf', value=_csrf)
|
||||
.form-group
|
||||
p Enter your email address below and we will send you password reset instructions.
|
||||
label.control-label(for='email') Email
|
||||
input.form-control(type='email', name='email', id='email', placeholder='Email', autofocus=true)
|
||||
.form-group
|
||||
button.btn.btn-primary(type='submit')
|
||||
i.fa.fa-key
|
||||
| Reset Password
|
||||
|
|
|
@ -243,11 +243,11 @@ block content
|
|||
a.btn.btn-lg.btn-block.btn-facebook.btn-link-social(href='/auth/facebook')
|
||||
i.fa.fa-facebook
|
||||
| Link Facebook with your account
|
||||
//- if (!user.github)
|
||||
// .col-xs-12
|
||||
// a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/auth/github')
|
||||
// i.fa.fa-github
|
||||
// | Link GitHub with your account
|
||||
- if (!user.github)
|
||||
.col-xs-12
|
||||
a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/auth/github')
|
||||
i.fa.fa-github
|
||||
| Link GitHub with your account
|
||||
- if (!user.linkedin)
|
||||
.col-xs-12
|
||||
a.btn.btn-lg.btn-block.btn-linkedin.btn-link-social(href='/auth/linkedin')
|
||||
|
|
Loading…
Reference in New Issue