branch: elpa/fj
commit 88bfc12d249766792d0712011861739c81f7e786
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>

    repo settings: check for admin permission before loading transient. #235
---
 fj-transient.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/fj-transient.el b/fj-transient.el
index 96d1d02824..dbd988c0b3 100644
--- a/fj-transient.el
+++ b/fj-transient.el
@@ -257,13 +257,18 @@ Provide current topics for adding/removing."
    ("C-c C-c" "Save settings" fj-update-repo)
    ("C-x C-k" :info "to revert all changes")]
   (interactive)
-  ;; FIXME: bail if we are not authorized to change this repo!
-  (if fj-current-repo
+  (if (not fj-current-repo)
+      (if (y-or-n-p "No repo. Try to use git config?")
+          (setq fj-current-repo (cadr (fj-repo-+-owner-from-git)))
+        (user-error "No repo")))
+  (if-let* ((data (fj-get-repo fj-current-repo
+                               (fj--repo-owner)))
+            ;; bail if we are not authorized to change this repo
+            ;; FIXME: how to confirm if admin required to change repo settings:
+            (perm (alist-get 'permissions data))
+            (admin-p (eq t (alist-get 'admin perm))))
       (transient-setup 'fj-repo-update-settings)
-    (if (y-or-n-p "No repo. Try to use git config?")
-        (if-let* ((repo-+-owner (fj-repo-+-owner-from-git))
-                  (fj-current-repo (cadr repo-+-owner)))
-            (transient-setup 'fj-repo-update-settings)))))
+    (user-error "You don't have permission to modify this repo")))
 
 (transient-define-suffix fj-update-user-settings (&optional args)
   "Update current user settings on the server."

Reply via email to