-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreset.html
62 lines (57 loc) · 1.66 KB
/
reset.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
layout: default
page: forgot
---
<h2>New Password</h2>
<form onsubmit="sendNewPassword()">
<input id="new" type="password" placeholder="new password" /><br>
<input id="match" type="password" placeholder="confirm password" onChange="checkPasswordMatch();" /><br>
<div id="divCheckPasswordMatch">Input a password</div><br>
<button onClick="sendNewPassword()"id="save" disabled>Save</button>
</form>
<script>
function checkPasswordMatch() {
var password = $("#new").val();
var confirmPassword = $("#match").val();
if (password != confirmPassword) {
$("#divCheckPasswordMatch").html("Passwords do not match!");
$('#save').attr('disabled',true);
}
else {
$("#divCheckPasswordMatch").html("Passwords match.");
$('#save').attr('disabled',false);
}
}
function sendNewPassword() {
var password = $('#match').val()
var token = String(decodeURIComponent(window.location.search.substring(1))).split("=")[1]
$.ajax({
url: getAPIPath() + "/reset/"+ token +"?password="+ password,
type: "POST",
xhrFields: {
withCredentials: true
},
headers: {
"Access-Control-Allow-Origin": true
},
crossDomain: true,
dataType: "json",
data: {},
success: function(data, status, xfr) {
console.log("Put Success: ", data, status, xfr);
window.location.href = '../'
},
error: function(request, error) {
console.log(
"Put Error: ",
JSON.stringify(data),
JSON.stringify(request)
);
callback(error);
}
});
}
$(document).ready(function () {
$("#new, #match").keyup(checkPasswordMatch);
});
</script>