PouchDB authentication: Create new CouchDB users
Asked Answered
G

1

7

I use the PouchDB-authentication plugin and I love it.

However, I'm a little confused about the signup process and maybe I don't use it the right way. I use it to create new users in my CouchDB database but I don't understand why it is associated with a specific database? Since I create CouchDB user before his specific database, I have to use a dummy database to create the new user:

// Create or get a database on the CouchDB server to further create a new user
var remoteDB = new PouchDB('http://169.254.197.198:5984/dummy');

// Signup to this db in order to create new user in the CouchDB server
remoteDB.signUp(document.register.username.value,
  document.register.password1.value).then(function (reponse){
}).then(function (reponse) {
  // handle response
}).catch(function (error) {
  // handle error
});

Question: Is there a way to create a new users independently of a database?

Goeselt answered 4/5, 2015 at 11:7 Comment(0)
A
9

It's a design flaw in pouchdb-authentication. Technically, your users are defined globally relative to the entire CouchDB server, but pouchdb-authentication tries to make things simpler by attaching itself to a PouchDB object linked to a single CouchDB database.

The easiest thing, if you want to continue using pouchdb-authentication, is yeah, to use a dummy database. Sorry about that; I couldn't come up with a better system. :/

Amulet answered 4/5, 2015 at 12:18 Comment(4)
Ok, thanks! Just wanted to know if I missed something.Goeselt
Hey, Nolan! Just wondering: is there some security issue or something like this prohibiting PouchDB from having a method like: PouchDB.signUp() which triggers a PUT request to http://{my-couchdb-host}/_users/org.couchdb.user:{username}? For now I'll use the dummy DB strategy, but this really dosn't feel right... =/Limpkin
@Amulet I am also interested in Matheus Dal'Pizzol 's questionKleper
Currently looks like signUp works even without dummy database. Am I not supposed to do that?Hluchy

© 2022 - 2024 — McMap. All rights reserved.