Last active
January 20, 2019 17:23
-
-
Save yackermann/720f62ba810acfc81339c2164ea0301d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById('login').addEventListener('submit', function(event) { | |
event.preventDefault(); | |
return getGetAssertionChallenge() | |
.then((getAssertionChallenge) => { | |
/*{ | |
"challenge": "Ld0vp5byLeFZBOpclgKP3BEc8AA4aBewYPlwbkgLh98", | |
"status": "ok" | |
}*/ | |
getAssertionChallenge = preformatGetAssertReq(getAssertionChallenge); | |
return navigator.credentials.get({ 'publicKey': getAssertionChallenge }) | |
}) | |
.then((newCredentialInfo) => { | |
newCredentialInfo = publicKeyCredentialToJSON(newCredentialInfo) | |
return getAssertionResponse(newCredentialInfo) | |
}) | |
.then((serverResponse) => { | |
if(serverResponse.status !== 'ok') | |
throw new Error('Error registering user! Server returned: ' + serverResponse.errorMessage); | |
alert('Success!'); | |
}) | |
.catch((error) => { | |
alert('FAIL' + error) | |
console.log('FAIL', error) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment