Add debug information for user.login
This commit is contained in:
parent
0779d07fe2
commit
c35f762d4e
|
@ -18,6 +18,7 @@ var Model = require('../loopback').Model
|
||||||
, ACL = require('./acl').ACL
|
, ACL = require('./acl').ACL
|
||||||
, assert = require('assert');
|
, assert = require('assert');
|
||||||
|
|
||||||
|
var debug = require('debug')('loopback:user');
|
||||||
/**
|
/**
|
||||||
* Default User properties.
|
* Default User properties.
|
||||||
*/
|
*/
|
||||||
|
@ -143,20 +144,24 @@ User.login = function (credentials, fn) {
|
||||||
var defaultError = new Error('login failed');
|
var defaultError = new Error('login failed');
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
|
debug('User: error reported from User.findOne: %j', err);
|
||||||
fn(defaultError);
|
fn(defaultError);
|
||||||
} else if(user) {
|
} else if(user) {
|
||||||
user.hasPassword(credentials.password, function(err, isMatch) {
|
user.hasPassword(credentials.password, function(err, isMatch) {
|
||||||
if(err) {
|
if(err) {
|
||||||
|
debug('User: error reported from User.hasPassword: %j', err);
|
||||||
fn(defaultError);
|
fn(defaultError);
|
||||||
} else if(isMatch) {
|
} else if(isMatch) {
|
||||||
user.accessTokens.create({
|
user.accessTokens.create({
|
||||||
ttl: Math.min(credentials.ttl || User.settings.ttl, User.settings.maxTTL)
|
ttl: Math.min(credentials.ttl || User.settings.ttl, User.settings.maxTTL)
|
||||||
}, fn);
|
}, fn);
|
||||||
} else {
|
} else {
|
||||||
|
debug('User: invalid password for user %s', query.email || query.username);
|
||||||
fn(defaultError);
|
fn(defaultError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
debug('User: no matching record found for user %s', query.email || query.username);
|
||||||
fn(defaultError);
|
fn(defaultError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue