Advertisement
Guest User

Untitled

a guest
Feb 21st, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. 403: function(jqXHR) {
  2. var error = jqXHR.responseText;
  3. console.log(error);
  4. }
  5.  
  6. HttpError: Wrong password<br> &nbsp; &nbsp;at
  7. c:Users...path...js:18:29<br> &nbsp; &nbsp;at
  8. c:Users...path...async.js:52:16<br> &nbsp; &nbsp;at
  9. Immediate._onImmediate
  10. (c:Users...path...node_modulesasynclibasync.js:1201:34)<br>
  11. &nbsp; &nbsp;at processImmediate [as _immediateCallback]
  12. (timers.js:383:17)
  13.  
  14. var error = JSON.parse(jqXHR.responseText);
  15. console.log(error.message);
  16.  
  17. SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
  18. .complete()
  19. m.Callbacks/j()
  20. m.Callbacks/k.fireWith()
  21. x()
  22. .send/b()
  23.  
  24. schema.statics.authorize = function(username, password, callback) {
  25. var User = this;
  26.  
  27. async.waterfall([
  28. function(callback) {
  29. User.findOne({username: username}, callback);
  30. },
  31. function(user, callback) {
  32. if (user) {
  33. if (user.checkPassword(password)) {
  34. callback(null, user);
  35. } else {
  36. callback(new AuthError("Wrong password"));
  37. }
  38. } else {
  39. var user = new User({username: username, password: password});
  40. user.save(function(err) {
  41. if (err) return callback(err);
  42. callback(null, user);
  43. });
  44. }
  45. }
  46. ], callback);
  47. };
  48.  
  49.  
  50. exports.User = mongoose.model('User', schema);
  51.  
  52.  
  53.  
  54.  
  55. function AuthError(message) {
  56. Error.captureStackTrace(this, AuthError);
  57.  
  58. this.message = message;
  59. }
  60.  
  61. util.inherits(AuthError, Error);
  62.  
  63. AuthError.prototype.name = 'AuthError';
  64.  
  65. exports.AuthError = AuthError;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement