diff --git a/lib/index-api.js b/lib/index-api.js index 65f5b8a1..aa238ac0 100644 --- a/lib/index-api.js +++ b/lib/index-api.js @@ -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) }