Skip to content

Commit

Permalink
change 403 error with 409 in adduser
Browse files Browse the repository at this point in the history
Because npm does only accept 409, see #184.
  • Loading branch information
rlidwka committed Feb 12, 2015
1 parent c49b069 commit 79e2ff2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/index-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ module.exports = function(config, auth, storage) {
}
auth.add_user(req.body.name, req.body.password, function(err, user) {
if (err) {
if (err.status < 500 && err.message === 'this user already exists') {
// with npm registering is the same as logging in
// so we replace message in case of conflict
return next( Error[409]('bad username/password, access denied') )
if (err.status >= 400 && err.status < 500) {
// With npm registering is the same as logging in,
// and npm accepts only an 409 error.
// So, changing status code here.
return next( Error[409](err.message) )
}
return next(err)
}
Expand Down

0 comments on commit 79e2ff2

Please sign in to comment.