Skip to content

Commit

Permalink
Handle invalid login
Browse files Browse the repository at this point in the history
  • Loading branch information
terakilobyte committed Jun 16, 2015
1 parent cb76aa1 commit 070c248
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion common/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function(User) {
res.cookie('access_token', accessToken.id, config);
res.cookie('userId', accessToken.userId, config);
}

debug('before pass login');
return req.logIn(user, function(err) {
if (err) {
return next(err);
Expand All @@ -54,6 +54,19 @@ module.exports = function(User) {
});
});

User.afterRemoteError('login', function(ctx, usr, next) {
var res = ctx.res;
var req = ctx.req;
// var args = ctx.args;


debug('after pass lgin');
req.flash('errors', {
msg: 'Invalid username or password.'
});
return res.redirect('/');
});

User.afterRemote('logout', function(ctx, result, next) {
var res = ctx.result;
res.clearCookie('access_token');
Expand Down

0 comments on commit 070c248

Please sign in to comment.