fxa-auth-server/sign_in.html

71 строка
1.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<style type="text/css">
html {
background: rgb(251, 246, 226);
}
form {
text-align: center;
color: rgb(95, 110, 117);
}
input {
font-size: x-large;
background: rgb(239, 232, 212);
color: rgb(95, 110, 117);
border: none;
}
#password {
width: 300px;
}
</style>
<script src="https://login.persona.org/authentication_api.js"></script>
<script>
var userEmail = ""
window.addEventListener('load', function () {
document.getElementById('form').addEventListener('submit', login)
})
function login(event) {
event.preventDefault()
var password = document.getElementById('password').value
var xhr = new XMLHttpRequest()
xhr.open("POST", "/login", true)
xhr.setRequestHeader("Content-type", "application/json")
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
return navigator.id.completeAuthentication()
}
navigator.id.raiseAuthenticationFailure('oops')
}
}
xhr.send(
JSON.stringify(
{
email: userEmail,
password: password
}
)
)
return false
}
navigator.id.beginAuthentication(
function (email) {
userEmail = email
}
)
</script>
</head>
<body>
<form id="form">
<input id="password" type="password" required autofocus>
<input type="submit" value="Go">
</form>
</body>
</html>