title: PouchDB remote authentication password storage in browser
body: <p>I'm playing around with in browser pouchdb and couchdb and and remote sync. This was all straight forward but now I'm at a roadblock that I'm not able to figure out myself.
  For security reasons every user of the website has its own datbase that is only accessable via the respective couchdb user.</p>
  
  <pre class="lang-js prettyprint-override"><code>const localDB = new PouchDB('test');
  const remoteDB = new PouchDB(process.env.REMOTE_DATABASE);
  
  const username = process.env.REMOTE_USER;
  const password = process.env.REMOTE_PASSWORD;
  
  
  remoteDB.login(username, password, (error, response) =&gt; {
      if (error) {
          console.error('Login failure', error)
      } else {
          console.log('Login success');
          dispatch('sync');
      }
  });
  
  console.log('sync');
  localDB.sync(remoteDB, {live: true})
      .on('change', response =&gt; {
          console.log(response);
      })
      .on('error', error =&gt; {
          console.error('Sync failure', error);
      });
  </code></pre>
  
  <p>To create a user I need a backend layer to handle user registration and creation. THis is now problem sind i can store the admin credentials "secure" on the server. Now my problem is how to handle the pouchdb user credentials in the browser. It would be possible to ask for the credentials on the first loading of the app and then storing it in the ram but this would lead to logging in on each reload of the page. Is there any way to use like cookie/token auth?</p>
  
  <p>Or is there a way to proxy the pouchdb connection through a backend proxy that handles the authentication!?</p>
  
  <p>Any tips would be appreciated.</p>