Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i {status: 401, name: "unauthorized", message: "Name or password is incorrect.", error: true, reason: "You are not a db or server admin."}
- application.service('Username', ['pouchDB',
- function(pouchDB)
- {
- new pouchDB('localhost/_users',
- {
- options: {
- auth: {
- username: '',
- password: '',
- },
- skipSetup: true
- }
- })
- return pouchDB;
- }
- application.factory('User', ['$q', 'Audit', 'Username',
- function($q, Audit, Username)
- {
- var data = {
- name: '',
- _id: "org.couchdb.user:",
- password: '',
- role: [],
- type: 'user',
- };
- var User = {};
- User.query = function(id)
- {
- var options = {
- descending: true,
- startkey: ['org.couchdb.user:'],
- include_docs: true,
- endkey: ['org.couchdb.user:', {}],
- };
- return Username.query(options).
- catch(function(error)
- {
- console.error(error);
- return $q.reject(error);
- }).
- then(function(response)
- {
- return response.rows.map(function(row)
- {
- return row.doc;
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement