Commit 2a3ca932 authored by JC Brand's avatar JC Brand

core: don't use Chrome-only check for web auth support

parent 22ff93c3
...@@ -491,7 +491,7 @@ async function attemptNonPreboundSession (credentials, automatic) { ...@@ -491,7 +491,7 @@ async function attemptNonPreboundSession (credentials, automatic) {
connect(await getLoginCredentials()); connect(await getLoginCredentials());
} else if (_converse.jid && (_converse.password || _converse.connection.pass)) { } else if (_converse.jid && (_converse.password || _converse.connection.pass)) {
connect(); connect();
} else if (!_converse.isTestEnv() && window.PasswordCredential) { } else if (!_converse.isTestEnv() && 'credentials' in navigator) {
connect(await getLoginCredentialsFromBrowser()); connect(await getLoginCredentialsFromBrowser());
} else { } else {
log.warn("attemptNonPreboundSession: Could not find any credentials to log in with"); log.warn("attemptNonPreboundSession: Could not find any credentials to log in with");
...@@ -774,6 +774,7 @@ async function onConnected (reconnecting) { ...@@ -774,6 +774,7 @@ async function onConnected (reconnecting) {
delete _converse.connection.reconnecting; delete _converse.connection.reconnecting;
_converse.connection.flush(); // Solves problem of returned PubSub BOSH response not received by browser _converse.connection.flush(); // Solves problem of returned PubSub BOSH response not received by browser
await _converse.setUserJID(_converse.connection.jid); await _converse.setUserJID(_converse.connection.jid);
/** /**
* Synchronous event triggered after we've sent an IQ to bind the * Synchronous event triggered after we've sent an IQ to bind the
* user's JID resource for this session. * user's JID resource for this session.
...@@ -912,10 +913,14 @@ async function getLoginCredentials () { ...@@ -912,10 +913,14 @@ async function getLoginCredentials () {
} }
async function getLoginCredentialsFromBrowser () { async function getLoginCredentialsFromBrowser () {
const creds = await navigator.credentials.get({'password': true}); try {
if (creds && creds.type == 'password' && u.isValidJID(creds.id)) { const creds = await navigator.credentials.get({'password': true});
await _converse.setUserJID(creds.id); if (creds && creds.type == 'password' && u.isValidJID(creds.id)) {
return {'jid': creds.id, 'password': creds.password}; await _converse.setUserJID(creds.id);
return {'jid': creds.id, 'password': creds.password};
}
} catch (e) {
log.error(e);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment