aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-09-16 08:59:41 -0500
committerColin Okay <colin@cicadas.surf>2022-09-16 08:59:41 -0500
commitb6c8013cbcd0100266f1bda436aa4075f70beee6 (patch)
treeea124354be27c9f098bbb2b64c0292b1cf53c773
parent19c805b4eaf8481fd627c4e6b569f2a0e28d3c3a (diff)
Add: assert-logged-in
-rw-r--r--lib/client.lisp14
-rw-r--r--lib/state.lisp5
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/client.lisp b/lib/client.lisp
index e6324aa..527a300 100644
--- a/lib/client.lisp
+++ b/lib/client.lisp
@@ -319,6 +319,7 @@ running the body. If such a oneliner can be found."
;;; ACCOUNT AND INVITE STUFF
(defun request-invite-code ()
+ (assert-logged-in)
(let ((invite
(jonathan:parse
(api:post-invite (api-token) *host*))))
@@ -338,18 +339,21 @@ running the body. If such a oneliner can be found."
(config-file))))
(defun change-pw (current new repeated)
+ (assert-logged-in)
(unless (equal new repeated)
(error "The new password doesn't match the repeated value. Double check."))
(api:put-contributor/who/password (handle) new repeated current (api-token) *host*))
(defun change-signature ()
+ (assert-logged-in)
(let ((new-sig
(prompt-for-signature)))
- (ensure-config)
- (api:put-contributor/who/signature (handle) (api-token) *host*
- :%content-type "application/json"
- :%body (jonathan:to-json (list :signature new-sig)))
- (format t "Your signature was changed.~%")))
+ (when new-sig
+ (ensure-config)
+ (api:put-contributor/who/signature (handle) (api-token) *host*
+ :%content-type "application/json"
+ :%body (jonathan:to-json (list :signature new-sig)))
+ (format t "Your signature was changed.~%"))))
(defun show-contributor (name)
diff --git a/lib/state.lisp b/lib/state.lisp
index 9a80245..37fb06f 100644
--- a/lib/state.lisp
+++ b/lib/state.lisp
@@ -39,6 +39,11 @@
(defun (setf api-token) (newvalue)
(setf (config-api-token *config*) newvalue))
+(defun assert-logged-in ()
+ "throws an error if no plausbile api token is part of the current
+ config."
+ (api-token))
+
(defun handle ()
(config-handle *config*))