diff --git a/data/web/templates/base.twig b/data/web/templates/base.twig index b7c0138f..a5e61ab3 100644 --- a/data/web/templates/base.twig +++ b/data/web/templates/base.twig @@ -182,12 +182,11 @@ function recursiveBase64StrToArrayBuffer(obj) { keyboard: false }); - $('#webauthn_status_auth').html('
Press to start authentication
'); + // validate WebAuthn tfa $('#start_webauthn_confirmation').click(function(){ $('#webauthn_status_auth').html('' + lang_tfa.init_webauthn + '
'); $(this).find('input[name=token]').focus(); - // If WebAuthn if(document.getElementById("webauthn_auth_data") !== null) { // Check Browser support if (!window.fetch || !navigator.credentials || !navigator.credentials.create) { @@ -195,19 +194,18 @@ function recursiveBase64StrToArrayBuffer(obj) { return; } + // fetch webauthn auth args window.fetch("/api/v1/get/webauthn-tfa-get-args", {method:'GET',cache:'no-cache'}).then(response => { return response.json(); }).then(json => { - console.log(json); if (json.success === false) throw new Error(); recursiveBase64StrToArrayBuffer(json); return json; }).then(getCredentialArgs => { - console.log(getCredentialArgs); + // get credentials return navigator.credentials.get(getCredentialArgs); }).then(cred => { - console.log(cred); return { id: cred.rawId ? arrayBufferToBase64(cred.rawId) : null, clientDataJSON: cred.response.clientDataJSON ? arrayBufferToBase64(cred.response.clientDataJSON) : null, @@ -215,23 +213,20 @@ function recursiveBase64StrToArrayBuffer(obj) { signature : cred.response.signature ? arrayBufferToBase64(cred.response.signature) : null }; }).then(JSON.stringify).then(function(AuthenticatorAttestationResponse) { - console.log(AuthenticatorAttestationResponse); - + // send request by submit var form = document.getElementById('webauthn_auth_form'); var auth = document.getElementById('webauthn_auth_data'); - console.log("Authenticate callback", AuthenticatorAttestationResponse); auth.value = AuthenticatorAttestationResponse; form.submit(); }).catch(function(err) { - if (typeof err.message === 'undefined') { - mailcow_alert_box(lang_fido2.fido2_validation_failed, "danger"); - } else { - mailcow_alert_box(lang_fido2.fido2_validation_failed + ":