forked from OPCFoundation/UA-CloudLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForgotPassword.cshtml
56 lines (52 loc) · 2.24 KB
/
ForgotPassword.cshtml
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
@page
@model ForgotPasswordModel
@{
ViewData["Title"] = "Forgot your password?";
var _reCaptchaUrl = $"{@Model.CaptchaSettings.ClientApiUrl}{@Model.CaptchaSettings.SiteKey}";
}
<h1>@ViewData["Title"]</h1>
<h2>Enter your email.</h2>
<hr />
<div class="row">
<div class="col-md-4">
<form id="resetForm" method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<span asp-validation-for="CaptchaResponseToken" class="text-danger"></span>
<div class="form-floating">
<input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" />
<label asp-for="Input.Email" class="form-label"></label>
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<input type="hidden" asp-for="CaptchaResponseToken" id="CaptchaResponseToken" />
@if (!Model.CaptchaSettings.Enabled)
{
<button id="resetSubmit" type="submit" class="w-100 btn btn-lg btn-primary">Reset Password</button>
}
else
{
<button id="resetSubmit" type="button" class="w-100 btn btn-lg btn-primary">Reset Password</button>
}
</form>
</div>
</div>
@section Scripts {
<partial name="_ValidationScriptsPartial" />
@if (Model.CaptchaSettings.Enabled)
{
<script src='@_reCaptchaUrl'></script>
<script>
function reCaptchaExecute() {
grecaptcha.execute('@Model.CaptchaSettings.SiteKey', { action: 'register' }).then(function (token) {
//populate token value in hidden field
document.getElementById("CaptchaResponseToken").value = token;
//submit form
$('#resetForm').submit();
});
}
//wire up reset button to execute reCaptcha before submitting
const btnResetSubmit = document.getElementById("resetSubmit");
btnResetSubmit.addEventListener('click', reCaptchaExecute, false);
//Note - if run on load, the token expires after 2 mins
</script>
}
}