From cdccaa9311cbe1c2af146cda0321886c4aad0879 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sat, 28 Jul 2012 22:49:18 +0200 Subject: [PATCH] Clean up data when login fails Before, when attempting to log in, and failing, the username and password were retained and subsequent attempts would also fail. Now the data is deleted and new login requests will start fresh. --- avandu.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/avandu.el b/avandu.el index c1a2afb..1e09e7f 100644 --- a/avandu.el +++ b/avandu.el @@ -125,6 +125,12 @@ doesn't sort the list, so you'll have to set that up in tt-rss. (set (make-local-variable 'revert-buffer-function) #'(lambda (ignore-auto noconfirm) (avandu-list)))) +(defun avandu--clear-data () + "Clean up login data. This makes for a clean slate next time." + (setq avandu-user nil + avandu-password nil + avandu--session-id nil)) + (defun avandu--get-status-id (results) "Get the status id from RESULTS." (cdr (assq 'status results))) @@ -139,6 +145,7 @@ otherwise. Signals an error if we're not logged in *and* login was unsuccesful." (unless (or (and avandu--session-id (avandu-logged-in-p)) (avandu-login)) + (avandu--clear-data) (error "Could not log in to tt-rss"))) (defmacro avandu-getset (var prompt &optional passwdp) @@ -214,7 +221,7 @@ in. This function returns t if we are, or nil if we're not." result))) (defun avandu-login () - "Send a request to log in to tt-rss. If `avandu-username' or + "Send a request to log in to tt-rss. If `avandu-user' or `avandu-password' have not been specified they will be asked for and saved in memory. This function returns t on succes, nil otherwise."