aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-auth.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-10 09:58:24 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-10 09:58:24 +0200
commit59a6bb22e51bfcb5d3840315848006272a8341ea (patch)
tree806b76cb3607447e4195c47e5e7b2abefeb5b743 /lisp/mastodon-auth.el
parentcec605b86a64582f3eb237aec36678cdf311a801 (diff)
audit auth.el
Diffstat (limited to 'lisp/mastodon-auth.el')
-rw-r--r--lisp/mastodon-auth.el37
1 files changed, 12 insertions, 25 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index e8ff282..96bf877 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -108,11 +108,9 @@ code. Copy this code and paste it in the minibuffer prompt."
NOTICE is displayed in vertical split occupying 50% of total
width. The buffer name of the buffer being displayed in the
window is BUFFER-NAME.
-
When optional argument ASK is given which should be a string, use
ASK as the minibuffer prompt. Return whatever user types in
response to the prompt.
-
When ASK is absent return nil."
(let ((buffer (get-buffer-create buffer-name))
(inhibit-read-only t)
@@ -170,25 +168,21 @@ When ASK is absent return nil."
(defun mastodon-auth--access-token ()
"Return the access token to use with `mastodon-instance-url'.
-
Generate/save token if none known yet."
(cond (mastodon-auth--token-alist
- ;; user variables are known and
- ;; initialised already.
+ ;; user variables are known and initialised.
(alist-get mastodon-instance-url mastodon-auth--token-alist
nil nil 'equal))
((plist-get (mastodon-client--active-user) :access_token)
- ;; user variables needs to initialised by reading from
- ;; plstore.
+ ;; user variables need to be read from plstore.
(push (cons mastodon-instance-url
(plist-get (mastodon-client--active-user) :access_token))
mastodon-auth--token-alist)
(alist-get mastodon-instance-url mastodon-auth--token-alist
nil nil 'equal))
((null mastodon-active-user)
- ;; user not aware of 2FA related changes and has not set the
- ;; `mastodon-active-user' properly. Make user aware and error
- ;; out.
+ ;; user not aware of 2FA-related changes and has not set
+ ;; `mastodon-active-user'. Make user aware and error out.
(mastodon-auth--show-notice mastodon-auth--user-unaware
"*mastodon-notice*")
(error "Variables not set properly"))
@@ -199,9 +193,7 @@ Generate/save token if none known yet."
(defun mastodon-auth--handle-token-response (response)
"Add token RESPONSE to `mastodon-auth--token-alist'.
-
The token is returned by `mastodon-auth--get-token'.
-
Handle any errors from the server."
(pcase response
((and (let token (plist-get response :access_token))
@@ -210,28 +202,23 @@ Handle any errors from the server."
(mastodon-client--store-access-token token))
(cdar (push (cons mastodon-instance-url token)
mastodon-auth--token-alist)))
-
(`(:error ,class :error_description ,error)
(error "Mastodon-auth--access-token: %s: %s" class error))
(_ (error "Unknown response from mastodon-auth--get-token!"))))
(defun mastodon-auth--get-account-name ()
"Request user credentials and return an account name."
- (alist-get
- 'acct
- (mastodon-http--get-json
- (mastodon-http--api
- "accounts/verify_credentials")
- nil
- :silent)))
+ (alist-get 'acct
+ (mastodon-http--get-json (mastodon-http--api
+ "accounts/verify_credentials")
+ nil
+ :silent)))
(defun mastodon-auth--get-account-id ()
"Request user credentials and return an account name."
- (alist-get
- 'id
- (mastodon-http--get-json
- (mastodon-http--api
- "accounts/verify_credentials"))))
+ (alist-get 'id
+ (mastodon-http--get-json (mastodon-http--api
+ "accounts/verify_credentials"))))
(defun mastodon-auth--user-acct ()
"Return a mastodon user acct name."