Skip to content

Commit

Permalink
address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Mar 23, 2017
1 parent 9c90462 commit 4e60e62
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions common/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,15 @@ module.exports = function(User) {
const err = new Error(`User ${userId} not found`);
Object.assign(err, {
code: 'USER_NOT_FOUND',
statusCode: 400,
statusCode: 401,
});
return cb(err);
}

inst.hasPassword(oldPassword, function(err, isMatch) {
if (err) return cb(err);
if (!isMatch) {
const err = new Error('Incorrect current password');
const err = new Error('Invalid current password');
Object.assign(err, {
code: 'INVALID_PASSWORD',
statusCode: 400,
Expand Down Expand Up @@ -869,7 +869,7 @@ module.exports = function(User) {
UserModel.remoteMethod(
'changePassword',
{
description: 'Change password of the current user.',
description: 'Change a user\'s password.',
accepts: [
{arg: 'id', type: 'any',
http: ctx => ctx.req.accessToken && ctx.req.accessToken.userId,
Expand Down
2 changes: 1 addition & 1 deletion test/user.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('users - integration', function() {
.expect(401, done);
});

it('changes password of the current user', function() {
it('updates the user\'s password', function() {
const User = app.models.User;
const credentials = {email: 'change@example.com', password: 'pass'};
return User.create(credentials)
Expand Down
10 changes: 5 additions & 5 deletions test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,8 +1308,8 @@ describe('User', function() {
success => { throw new Error('changePassword should have failed'); },
err => {
// workaround for chai problem
// object tested must be an array, an object, or a string,
// but error given
// object tested must be an array, an object,
// or a string, but error given
const props = Object.assign({}, err);
expect(props).to.contain({
code: 'INVALID_PASSWORD',
Expand All @@ -1318,7 +1318,7 @@ describe('User', function() {
});
});

it('fails with 404 for unknown user id', () => {
it('fails with 401 for unknown user id', () => {
return User.changePassword('unknown-id', 'pass', 'pass').then(
success => { throw new Error('changePassword should have failed'); },
err => {
Expand All @@ -1328,12 +1328,12 @@ describe('User', function() {
const props = Object.assign({}, err);
expect(props).to.contain({
code: 'USER_NOT_FOUND',
statusCode: 400,
statusCode: 401,
});
});
});

it('forwards "options" argument', () => {
it('forwards the "options" argument', () => {
const options = {testFlag: true};
const observedOptions = [];

Expand Down

0 comments on commit 4e60e62

Please sign in to comment.