瀏覽代碼

Initial support for the CredentialsContainer web API

JC Brand 6 年之前
父節點
當前提交
699fe0df63
共有 2 個文件被更改,包括 7 次插入0 次删除
  1. 1 0
      CHANGES.md
  2. 6 0
      src/headless/converse-core.js

+ 1 - 0
CHANGES.md

@@ -1,6 +1,7 @@
 # Changelog
 
 ## 5.0.0 (Unreleased)
+- Initial support for the [CredentialsContainer](https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer) web API
 - Allow for synchronous events. When a synchronous event is fired, Converse will
   wait for all promises returned by the event's handlers to finish before continuing.
 - Properly handle message correction being received before the corrected message

+ 6 - 0
src/headless/converse-core.js

@@ -1346,6 +1346,12 @@ _converse.initialize = async function (settings, callback) {
             }
         } else if (reconnecting) {
             this.autoLogin();
+        } else if (window.PasswordCredential) {
+            const creds = await navigator.credentials.get({'password': true});
+            if (creds && creds.type == 'password' && u.isValidJID(creds.id)) {
+                setUserJID(creds.id);
+                this.autoLogin({'jid': creds.id, 'password': creds.password});
+            }
         }
     };