summaryrefslogtreecommitdiff
path: root/lisp/gnus/auth-source.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2009-02-05 02:34:34 +0000
committerMiles Bader <miles@gnu.org>2009-02-05 02:34:34 +0000
commit3b36c17e9d67d74a8bc50e7a53a23da7d5f94e22 (patch)
treec2ca87dc1f8bb06d2b0608ef939d51f0b28e5d2e /lisp/gnus/auth-source.el
parenta9e2203dea54ba2d777e0df0415f65bb105272f1 (diff)
downloademacs-3b36c17e9d67d74a8bc50e7a53a23da7d5f94e22.tar.gz
Merge from gnus--devo--0
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1537
Diffstat (limited to 'lisp/gnus/auth-source.el')
-rw-r--r--lisp/gnus/auth-source.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index 27de702b976..1bec08f076f 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -163,12 +163,20 @@ Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
(interactive "slogin/password: \nsHost: \nsProtocol: \n") ;for testing
(remhash (format "%s %s:%s" mode host protocol) auth-source-cache))
+(defun auth-source-forget-all-cached ()
+ "Forget all cached auth-source authentication tokens."
+ (interactive)
+ (setq auth-source-cache (make-hash-table :test 'equal)))
+
(defun auth-source-user-or-password (mode host protocol)
- "Find user or password (from the string MODE) matching HOST and PROTOCOL."
+ "Find MODE (string or list of strings) matching HOST and PROTOCOL.
+MODE can be \"login\" or \"password\" for example."
(gnus-message 9
"auth-source-user-or-password: get %s for %s (%s)"
mode host protocol)
- (let* ((cname (format "%s %s:%s" mode host protocol))
+ (let* ((listy (listp mode))
+ (mode (if listy mode (list mode)))
+ (cname (format "%s %s:%s" mode host protocol))
(found (gethash cname auth-source-cache)))
(if found
(progn
@@ -176,7 +184,7 @@ Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
"auth-source-user-or-password: cached %s=%s for %s (%s)"
mode
;; don't show the password
- (if (equal mode "password") "SECRET" found)
+ (if (member "password" mode) "SECRET" found)
host protocol)
found)
(dolist (choice (auth-source-pick host protocol))
@@ -191,8 +199,9 @@ Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
"auth-source-user-or-password: found %s=%s for %s (%s)"
mode
;; don't show the password
- (if (equal mode "password") "SECRET" found)
+ (if (member "password" mode) "SECRET" found)
host protocol)
+ (setq found (if listy found (car-safe found)))
(when auth-source-do-cache
(puthash cname found auth-source-cache)))
(return found)))))