branch: elpa/totp-auth
commit 6acb5f3cdac840fc2d1e5c4b73a90f4c035d7116
Author: Vivek Das Mohapatra <vi...@collabora.com>
Commit: Vivek Das Mohapatra <vi...@collabora.com>

    totp-auth-add-secret: support noninteractive calls
    
    The noninteractive path through this function was not
    implemented - it now works as documented.
---
 totp-auth.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/totp-auth.el b/totp-auth.el
index 2c65b74cd9..df6b5b6e05 100644
--- a/totp-auth.el
+++ b/totp-auth.el
@@ -798,6 +798,15 @@ DIGITS defaults to 6 if not otherwise specified."
        (setq s (totp-auth-unwrap-otpauth-url u))
        (mapcar (lambda (k) (cdr (assq k s)) )
                '(:secret :service :user :digits)))))
+  (let (s u)
+    (when (and (not (called-interactively-p 'any))
+               (setq u (url-generic-parse-url secret))
+               (equal (url-type u) "otpauth"))
+      (setq s       (totp-auth-unwrap-otpauth-url u)
+            secret  (cdr (assq :secret  s))
+            user    (or user    (cdr (assq :user    s)))
+            service (or service (cdr (assq :service s)))
+            digits  (or digits  (cdr (assq :digits  s)))) ))
   (totp-auth-save-secret `((:service . ,service)
                            (:user    . ,user)
                            (:secret  . ,secret)

Reply via email to