Skip to content

Commit 8f87d9e

Browse files
committed
update resend otp function
1 parent a242f00 commit 8f87d9e

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

web-assets/css/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,14 @@ select::-ms-expand {
675675
width: 20px;
676676
}
677677

678+
.messages .message.notify {
679+
background-color: #079531b8;
680+
color: #ffffff;
681+
}
682+
.messages .message.notify:before {
683+
content: "\2713";
684+
}
685+
678686
/** Desktop + tab - specific CSS **/
679687
@media (min-width: 768px) {
680688
.center-align-card .page-content {

web-assets/js/otp.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ $(document).ready(function () {
2020
$("#error").closest(".message").fadeOut();
2121
$("#error").html("");
2222
let formAction = qs["formAction"];
23-
console.log(formAction)
2423
const opt1 = 'https://auth.{{DOMAIN}}/continue';
2524
const opt2 = 'https://{{AUTH0DOMAIN}}/continue';
2625
if (!formAction.startsWith(opt1) && !formAction.startsWith(opt2)) {
2726
// looks like XSS attack
28-
console.log("err")
2927
formAction = "#";
3028
}
3129
$('#verifyOtp').attr('action', formAction);
@@ -34,6 +32,42 @@ $(document).ready(function () {
3432
$("#verifyOtp").submit();
3533
return false;
3634
});
35+
const resendToken = qs["resendToken"];
36+
const userId = qs["userId"];
37+
if (resendToken && userId) {
38+
const apiServerUrl = "https://api.{{DOMAIN}}.com/v3/users";
39+
$("#resend").click(function () {
40+
$.ajax({
41+
type: "POST",
42+
url: apiServerUrl + "/resendOtpEmail",
43+
contentType: "application/json",
44+
mimeType: "application/json",
45+
data: JSON.stringify({
46+
"param": {
47+
userId, resendToken
48+
}
49+
}),
50+
dataType: "json",
51+
success: function (result) {
52+
$("#notify").html("Email sent");
53+
$("#notify").closest(".message").fadeIn();
54+
$("#resend").hide();
55+
},
56+
error: function (error) {
57+
if (error.responseJSON && error.responseJSON.result) {
58+
$("#error").html(error.responseJSON.result.content);
59+
$("#error").closest(".message").fadeIn();
60+
$("#resend").hide();
61+
} else {
62+
$("#error").html("Unknown Error");
63+
$("#error").closest(".message").fadeIn();
64+
}
65+
}
66+
});
67+
});
68+
} else {
69+
$("#resend").hide();
70+
}
3771

3872
/**
3973
* Script for field placeholder

web-assets/static-pages/otp.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ <h1 id="page-title-heading" class="page-title-heading">
3737
<span class="clip-me">Close</span>
3838
</span>
3939
</div>
40+
<div role="alert" class="message notify">
41+
<div id="notify" class="message-content"></div>
42+
<span class="close-error" tabindex="0">
43+
<span class="clip-me">Close</span>
44+
</span>
45+
</div>
4046
</div>
4147
<form method="GET" id="verifyOtp" action="#">
4248
<input id="state" name="state" value="" type="hidden" />

0 commit comments

Comments
 (0)