Skip to content

Instantly share code, notes, and snippets.

@tlvince
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlvince/c6e242d8b2d9fa178174 to your computer and use it in GitHub Desktop.
Save tlvince/c6e242d8b2d9fa178174 to your computer and use it in GitHub Desktop.
PouchDB authentication - require_valid_user testcase
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script src="https://cdn.jsdelivr.net/pouchdb/3.0.6/pouchdb.min.js"></script>
<script src="https://rawgit.com/nolanlawson/pouchdb-authentication/master/dist/pouchdb.authentication.js"></script>
<script>
// Prevent nonce
var options = {
ajax: {
cache: true
}
}
var db = new PouchDB('http://localhost:5984/test');
db.login('admin', 'admin')
.then(function() {
return db.allDocs();
})
.then(function(docs) {
console.log(docs);
})
.catch(function(err) {
console.error(err);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment