Files
node-red-alexa-home-skill-web/views/pages/lostPassword.ejs
2017-03-23 14:07:42 +00:00

39 lines
1.4 KiB
Plaintext

<% include ../fragments/header.ejs %>
<div class="container main-content">
<div id="changePassword">
<h3>Enter email address</h3>
<label style="width: 75px" for="email">Email:</label>
<input type="email" id="email"/>
<br>
<button id="registerButton">Submit</button>
<script type="application/javascript">
var xhr = new XMLHttpRequest();
var button = document.getElementById('registerButton');
button.onclick = function(){
var email = document.getElementById('email').value;
if (email.indexOf('@') == -1) {
alert("That doesn't look like a valid email address");
return;
} else {
var params = 'email=' + encodeURIComponent(email);
xhr.open('POST', '/lostPassword',true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () {
if( xhr.readyState == 4 && xhr.status == 200) {
//new lostpassword token created
window.location = '/';
} else if (xhr.readyState == 4 && xhr.status == 404) {
//show error
alert(xhr.responseText);
}
}
xhr.send(params);
}
}
</script>
</div>
</div>
<% include ../fragments/footer.ejs %>