I'm using PouchDB 4.0. To test the credentials to a remote CouchDB server, I use the following code:
testCredentials: function(credentials, callback){
var remoteDb = new PouchDB('http://X.X.X.X/dbName', {
auth: {
username: credentials.username,
password: credentials.password
}
});
remoteDb.info(function(err, info) {
if (err) {
if(err.status == 401)
callback("unauthorized");
else {
console.log(err);
callback("error");
}
} else {
callback("success");
}
});
}
When I pass invalid credentials (e.g. existing user but invalid password), I see a 401 error returned inside the CouchDB log file. However, PouchDb always returns the following 500 error:
{"status":500,
"name":"unknown_error",
"message":"Database encountered an unknown error",
"error":true}
The same problem occurs when using the pouchdb-authentication plugin. This code worked perfectly in previous versions of PouchDB.