pouchdb-community / pouchdb-authentication

User authentication plugin for PouchDB and CouchDB.
Apache License 2.0
776 stars 118 forks source link

404 in getUser only on ios first time I open app #250

Open goltra opened 6 years ago

goltra commented 6 years ago

Hello, I have a weird problem. I'm doing login() and after getUser() with your plugin and only on iOs and only first time I open app, I get 404. This is the error:

{"error":"not_found","reason":"missing","status":404,"name":"not_found","message":"missing"}

If I close my app and open again, all is working fine.

This is my code:

PouchDB.plugin(PouchAuth);
  this.auth = new PouchDB(this.couchserver + '_users', {
      skip_setup: true
});
let ajaxOps = {
            ajax: {
                headers: {
                    Authorization: 'Basic ' + window.btoa(usuario + ':' + password)
                },
                body: {
                    name: usuario,
                    password: password
                }
            }
        }
        this.auth.logIn(usuario, password, ajaxOps).then(data => {
            if (data.ok != undefined && data.ok == true) {
                this.auth.getUser(usuario).then(data => {
                    resolve(data);
                }, err => {
                    reject(err);
                })
            }
        }

As I said, if I close my app and run again and it works fine. I can figure out where is the problem.

chisNaN commented 5 years ago

kind same problem here https://github.com/pouchdb-community/pouchdb-authentication/issues/232 will not work on MACOS safari neither but with PWA integration there is no problem)))