0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

change 403 error with 409 in adduser

Because npm does only accept 409, see #184.
This commit is contained in:
Alex Kocharin 2015-02-12 14:18:47 +03:00
parent c49b0699c2
commit 79e2ff2ee8

View file

@ -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)
}