diff --git a/views/bootstrap/class.Login.php b/views/bootstrap/class.Login.php index 6b78543c8..52f87d95e 100644 --- a/views/bootstrap/class.Login.php +++ b/views/bootstrap/class.Login.php @@ -76,126 +76,6 @@ $(document).ready( function() { }, }); }); -function webauthnAuthenticate(key, cb){ - var pk = JSON.parse(key); - var originalChallenge = pk.challenge; - pk.challenge = new Uint8Array(pk.challenge); - pk.allowCredentials.forEach(function(k, idx){ - pk.allowCredentials[idx].id = new Uint8Array(k.id); - }); - /* ask the browser to prompt the user */ - navigator.credentials.get({publicKey: pk}) - .then(function(aAssertion) { - // console.log("Credentials.Get response: ", aAssertion); - var ida = []; - (new Uint8Array(aAssertion.rawId)).forEach(function(v){ ida.push(v); }); - var cd = JSON.parse(String.fromCharCode.apply(null, - new Uint8Array(aAssertion.response.clientDataJSON))); - var cda = []; - (new Uint8Array(aAssertion.response.clientDataJSON)).forEach(function(v){ cda.push(v); }); - var ad = []; - (new Uint8Array(aAssertion.response.authenticatorData)).forEach(function(v){ ad.push(v); }); - var sig = []; - (new Uint8Array(aAssertion.response.signature)).forEach(function(v){ sig.push(v); }); - var info = { - type: aAssertion.type, - originalChallenge: originalChallenge, - rawId: ida, - response: { - authenticatorData: ad, - clientData: cd, - clientDataJSONarray: cda, - signature: sig - } - }; - cb(true, JSON.stringify(info)); - }) - .catch(function (aErr) { - if (("name" in aErr) && (aErr.name == "AbortError" || aErr.name == "NS_ERROR_ABORT" || - aErr.name == "NotAllowedError")) { - cb(false, 'abort'); - } else { - cb(false, aErr.toString()); - } - }); -} - - $(function(){ - $('#webauthnlogin').click(function(ev){ - var self = $(this); - ev.preventDefault(); - - if(!$('#loginusername').val()) { - noty({ - text: '', - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 3000, - }); - return; - } - $.ajax({url: '../op/op.Login.php', - method: 'POST', - data: {action: 'preparelogin', login: $('#loginusername').val()}, - dataType: 'json', - success: function(j){ - /* activate the key and get the response */ - webauthnAuthenticate(j.challenge, function(success, info){ - if (success) { - $.ajax({url: '../op/op.Login.php', - method: 'POST', - data: {action: 'login', login: $('#loginusername').val(), logininfo: info}, - dataType: 'json', - success: function(j){ - noty({ - text: 'login completed successfully', - type: 'success', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - _timeout: 1500, - }); - window.location = j; - }, - error: function(xhr, status, error){ - noty({ - text: 'login failed: '+error+": "+xhr.responseText, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - _timeout: 1500, - }); - } - }); - } else { - noty({ - text: info, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - _timeout: 1500, - }); - } - }); - }, - - error: function(xhr, status, error){ - noty({ - text: "couldn't initiate login: "+error+": "+xhr.responseText, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - _timeout: 1500, - }); - } - }); - }); - }); errorMsg(htmlspecialchars($msg)); ?> -
+ contentContainerStart(); if ($refer) { @@ -234,7 +114,7 @@ function webauthnAuthenticate(key, cb){ array( 'element'=>'input', 'type'=>'text', - 'id'=>'loginusername', + 'id'=>'login', 'name'=>'login', 'placeholder'=>getMLText('user_login'), 'autocomplete'=>'on',