Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. i {status: 401, name: "unauthorized", message: "Name or password is incorrect.", error: true, reason: "You are not a db or server admin."}
  2.  
  3. application.service('Username', ['pouchDB',
  4. function(pouchDB)
  5. {
  6. new pouchDB('localhost/_users',
  7. {
  8. options: {
  9. auth: {
  10. username: '',
  11. password: '',
  12. },
  13. skipSetup: true
  14. }
  15. })
  16. return pouchDB;
  17. }
  18.  
  19. application.factory('User', ['$q', 'Audit', 'Username',
  20. function($q, Audit, Username)
  21. {
  22. var data = {
  23. name: '',
  24. _id: "org.couchdb.user:",
  25. password: '',
  26. role: [],
  27. type: 'user',
  28. };
  29.  
  30. var User = {};
  31.  
  32. User.query = function(id)
  33. {
  34. var options = {
  35. descending: true,
  36. startkey: ['org.couchdb.user:'],
  37. include_docs: true,
  38. endkey: ['org.couchdb.user:', {}],
  39. };
  40.  
  41. return Username.query(options).
  42. catch(function(error)
  43. {
  44. console.error(error);
  45. return $q.reject(error);
  46. }).
  47. then(function(response)
  48. {
  49. return response.rows.map(function(row)
  50. {
  51. return row.doc;
  52. });
  53. });
  54. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement