ui: webauthn registration: code cleanup long variable name

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-03-03 14:05:02 +01:00
parent 7f9eef1d47
commit 5c4203b20c

View File

@ -73,20 +73,21 @@ Ext.define('PBS.window.AddWebauthn', {
throw "server did not respond with a challenge"; throw "server did not respond with a challenge";
} }
let challenge_obj = JSON.parse(data.challenge); let creds = JSON.parse(data.challenge);
// Fix this up before passing it to the browser, but keep a copy of the original // Fix this up before passing it to the browser, but keep a copy of the original
// string to pass in the response: // string to pass in the response:
let challenge_str = challenge_obj.publicKey.challenge; let challenge_str = creds.publicKey.challenge;
challenge_obj.publicKey.challenge = PBS.Utils.base64url_to_bytes(challenge_str); creds.publicKey.challenge = PBS.Utils.base64url_to_bytes(challenge_str);
challenge_obj.publicKey.user.id = creds.publicKey.user.id =
PBS.Utils.base64url_to_bytes(challenge_obj.publicKey.user.id); PBS.Utils.base64url_to_bytes(creds.publicKey.user.id);
// convert existing authenticators structure // convert existing authenticators structure
challenge_obj.publicKey.excludeCredentials = creds.publicKey.excludeCredentials =
(challenge_obj.publicKey.excludeCredentials || []).map((cred) => ({ (creds.publicKey.excludeCredentials || [])
id: PBS.Utils.base64url_to_bytes(cred.id), .map((credential) => ({
type: cred.type, id: PBS.Utils.base64url_to_bytes(credential.id),
type: credential.type,
})); }));
let msg = Ext.Msg.show({ let msg = Ext.Msg.show({
@ -97,7 +98,7 @@ Ext.define('PBS.window.AddWebauthn', {
let token_response; let token_response;
try { try {
token_response = await navigator.credentials.create(challenge_obj); token_response = await navigator.credentials.create(creds);
} catch (error) { } catch (error) {
let errmsg = error.message; let errmsg = error.message;
if (error.name === 'InvalidStateError') { if (error.name === 'InvalidStateError') {