Updated passport local strategy to use usernameEmail usernameField
This commit is contained in:
@ -18,7 +18,7 @@ passport.deserializeUser(function(id, done) {
|
||||
});
|
||||
|
||||
passport.use(new LocalStrategy({
|
||||
usernameField: 'email'
|
||||
usernameField: 'usernameEmail'
|
||||
},
|
||||
function(email, password, done) {
|
||||
User.findOne({ email: email }, function(err, user) {
|
||||
|
@ -33,10 +33,7 @@ exports.getLogin = function(req, res) {
|
||||
*/
|
||||
exports.postLogin = function(req, res, next) {
|
||||
passport.authenticate('local', function(err, user, info) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return next(err);
|
||||
}
|
||||
if (err) return next(err);
|
||||
if (!user) {
|
||||
req.flash('messages', info.message);
|
||||
return res.redirect('/login');
|
||||
|
@ -1,46 +1,43 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
.login-wrapper
|
||||
.login-container
|
||||
h3.text-center
|
||||
span.text-primary PROJECT
|
||||
span.text-muted NAME
|
||||
form(method='POST')
|
||||
.form-group
|
||||
input.form-control(type='text', name='usernameOrEmail', id='usernameOrEmail', placeholder='Username or Email', autofocus='')
|
||||
.form-group
|
||||
input.form-control(type='password', name='password', id='password', placeholder='Password')
|
||||
button(type='submit')
|
||||
i.fa.fa-chevron-right
|
||||
.form-options.clearfix
|
||||
a.pull-right(href='#') Forgot password?
|
||||
.text-left
|
||||
label.checkbox
|
||||
input(type='checkbox')
|
||||
span Remember me
|
||||
.row
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-primary.btn-block.facebook(href='/auth/facebook')
|
||||
i.fa.fa-facebook
|
||||
| Facebook
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-danger.btn-block.google(href='/auth/google')
|
||||
i.fa.fa-google-plus
|
||||
| Google
|
||||
.row
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-info.btn-block.twitter(href='/auth/twitter')
|
||||
i.fa.fa-twitter
|
||||
| Twitter
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-default.btn-block.github(href='/auth/github')
|
||||
i.fa.fa-github
|
||||
| GitHub
|
||||
p Don't have an account yet?
|
||||
a(href='/signup') Sign up now
|
||||
|
||||
|
||||
if messages.length
|
||||
.alert.alert-danger
|
||||
strong= messages
|
||||
if messages.length
|
||||
.alert.alert-danger
|
||||
strong= messages
|
||||
.login-container
|
||||
h3.text-center
|
||||
span.text-primary PROJECT
|
||||
span.text-muted NAME
|
||||
form(method='POST')
|
||||
.form-group
|
||||
input.form-control(type='text', name='usernameEmail', id='usernameEmail', placeholder='Username or Email', autofocus='')
|
||||
.form-group
|
||||
input.form-control(type='password', name='password', id='password', placeholder='Password')
|
||||
button(type='submit')
|
||||
i.fa.fa-chevron-right
|
||||
.form-options.clearfix
|
||||
a.pull-right(href='#') Forgot password?
|
||||
.text-left
|
||||
label.checkbox
|
||||
input(type='checkbox')
|
||||
span Remember me
|
||||
.row
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-primary.btn-block.facebook(href='/auth/facebook')
|
||||
i.fa.fa-facebook
|
||||
| Facebook
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-danger.btn-block.google(href='/auth/google')
|
||||
i.fa.fa-google-plus
|
||||
| Google
|
||||
.row
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-info.btn-block.twitter(href='/auth/twitter')
|
||||
i.fa.fa-twitter
|
||||
| Twitter
|
||||
.col-xs-6.col-sm-6.col-md-6
|
||||
a.btn.btn-default.btn-block.github(href='/auth/github')
|
||||
i.fa.fa-github
|
||||
| GitHub
|
||||
p Don't have an account yet?
|
||||
a(href='/signup') Sign up now
|
Reference in New Issue
Block a user