Merge pull request #3784 from zbarbuto/fix/user-status-code

Use statusCode prop for user errors
This commit is contained in:
Raymond Feng 2018-01-31 15:16:27 -08:00 committed by GitHub
commit d23ff84587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -326,7 +326,7 @@ module.exports = function(User) {
var err;
if (!tokenId) {
err = new Error(g.f('{{accessToken}} is required to logout'));
err.status = 401;
err.statusCode = 401;
process.nextTick(fn, err);
return fn.promise;
}
@ -336,7 +336,7 @@ module.exports = function(User) {
fn(err);
} else if ('count' in info && info.count === 0) {
err = new Error(g.f('Could not find {{accessToken}}'));
err.status = 401;
err.statusCode = 401;
fn(err);
} else {
fn();

View File

@ -1280,7 +1280,7 @@ describe('User', function() {
it('fails when accessToken is not provided', function(done) {
User.logout(undefined, function(err) {
expect(err).to.have.property('message');
expect(err).to.have.property('status', 401);
expect(err).to.have.property('statusCode', 401);
done();
});
});
@ -1288,7 +1288,7 @@ describe('User', function() {
it('fails when accessToken is not found', function(done) {
User.logout('expired-access-token', function(err) {
expect(err).to.have.property('message');
expect(err).to.have.property('status', 401);
expect(err).to.have.property('statusCode', 401);
done();
});
});