Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 403: function(jqXHR) {
- var error = jqXHR.responseText;
- console.log(error);
- }
- HttpError: Wrong password<br> at
- c:Users...path...js:18:29<br> at
- c:Users...path...async.js:52:16<br> at
- Immediate._onImmediate
- (c:Users...path...node_modulesasynclibasync.js:1201:34)<br>
- at processImmediate [as _immediateCallback]
- (timers.js:383:17)
- var error = JSON.parse(jqXHR.responseText);
- console.log(error.message);
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- .complete()
- m.Callbacks/j()
- m.Callbacks/k.fireWith()
- x()
- .send/b()
- schema.statics.authorize = function(username, password, callback) {
- var User = this;
- async.waterfall([
- function(callback) {
- User.findOne({username: username}, callback);
- },
- function(user, callback) {
- if (user) {
- if (user.checkPassword(password)) {
- callback(null, user);
- } else {
- callback(new AuthError("Wrong password"));
- }
- } else {
- var user = new User({username: username, password: password});
- user.save(function(err) {
- if (err) return callback(err);
- callback(null, user);
- });
- }
- }
- ], callback);
- };
- exports.User = mongoose.model('User', schema);
- function AuthError(message) {
- Error.captureStackTrace(this, AuthError);
- this.message = message;
- }
- util.inherits(AuthError, Error);
- AuthError.prototype.name = 'AuthError';
- exports.AuthError = AuthError;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement