couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [couchdb-fauxton] branch master updated: correct initial fetch() of _security to use credentials (#929)
Date Thu, 31 Aug 2017 08:38:40 GMT
This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git


The following commit(s) were added to refs/heads/master by this push:
     new 3bc13d0  correct initial fetch() of _security to use credentials (#929)
3bc13d0 is described below

commit 3bc13d09529d28abd9764fd8dce1f7b6f787e345
Author: Will Young <lost.networking@gmail.com>
AuthorDate: Thu Aug 31 10:38:39 2017 +0200

    correct initial fetch() of _security to use credentials (#929)
    
    * db security form does not populate with existing object, (#929)
---
 app/addons/permissions/actions.js | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/app/addons/permissions/actions.js b/app/addons/permissions/actions.js
index 8da6a4b..969768b 100644
--- a/app/addons/permissions/actions.js
+++ b/app/addons/permissions/actions.js
@@ -28,9 +28,26 @@ export const receivedPermissions = json => {
 };
 
 export const fetchPermissions = url => dispatch => {
-  return fetch(url, { headers: { 'Accept': 'application/json' }})
-    .then(res => res.json())
-    .then(json => dispatch(receivedPermissions(json)));
+  return fetch(url, {
+    headers: {'Accept': 'application/json' },
+    credentials: 'include'
+  })
+  .then((res) => res.json())
+  .then(json => {
+     if (json.error && json.reason) {
+       dispatch(receivedPermissions(
+         {admins:{roles:["_admin"]}, members:{roles:["_admin"]}}));
+       throw new Error(json.reason);
+     }
+     dispatch(receivedPermissions(json));
+  })
+  .catch((err) => {
+     FauxtonAPI.addNotification({
+       msg: 'Failed to retrieve permissions. Please try again. Reason:'
+         + err.message,
+       type: 'error'
+     });
+  });
 };
 
 export const setPermissionOnObject = (p, section, type, value) => {

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <commits@couchdb.apache.org>'].

Mime
View raw message