Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix for API timeout #318

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show().removeClass("d-none");
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'col-12 alert alert-success').slideDown();
Expand All @@ -55,8 +62,8 @@
else {
$('#loginmessage').attr('class', 'alert alert-danger').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@
<div class="form-group row dnnFormRequired">
<label class="col-sm-4 col-form-label" for="customeremail">@Localization.GetString("EmailAddress"):</label>
<div class="col-sm-6 offset-sm-0">
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new {@class = "form-control"})
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new { @class = "form-control" })
}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show();
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'dnnFormMessage dnnFormSuccess').slideDown();
Expand All @@ -49,8 +56,8 @@
else {
$('#loginmessage').attr('class', 'dnnFormMessage dnnFormError').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@

<div id="hcTabGuest" class="dnnClear hcTabPane Hidden">
<div class="dnnFormItem dnnFormRequired">
<label class="dnnLabel">@Localization.GetString("EmailAddress"):</label>
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail)
<label class="dnnLabel">@Localization.GetString("EmailAddress"):</label>
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail)
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show();
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'dnnFormMessage dnnFormSuccess').slideDown();
Expand All @@ -55,8 +62,8 @@
else {
$('#loginmessage').attr('class', 'dnnFormMessage dnnFormError').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
<div class="form-group dnnFormRequired">
<label class="col-sm-4 control-label">@Localization.GetString("EmailAddress"):</label>
<div class="col-sm-offset-0 col-sm-6">
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new {@class = "form-control"})
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new {@class = "form-control"})
}
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show().removeClass("d-none");
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'col-12 alert alert-success').slideDown();
Expand All @@ -55,8 +62,8 @@
else {
$('#loginmessage').attr('class', 'alert alert-danger').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@
<div class="form-group row dnnFormRequired">
<label class="col-sm-4 col-form-label" for="customeremail">@Localization.GetString("EmailAddress"):</label>
<div class="col-sm-6 offset-sm-0">
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new {@class = "form-control"})
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new { @class = "form-control" })
}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show();
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'dnnFormMessage dnnFormSuccess').slideDown();
Expand All @@ -49,8 +56,8 @@
else {
$('#loginmessage').attr('class', 'dnnFormMessage dnnFormError').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show();
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'dnnFormMessage dnnFormSuccess').slideDown();
Expand All @@ -49,8 +56,8 @@
else {
$('#loginmessage').attr('class', 'dnnFormMessage dnnFormError').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@

<div id="hcTabGuest" class="dnnClear hcTabPane Hidden">
<div class="dnnFormItem dnnFormRequired">
<label class="dnnLabel">@Localization.GetString("EmailAddress"):</label>
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail)
<label class="dnnLabel">@Localization.GetString("EmailAddress"):</label>
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail)
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<div id="hcTabGuest" class="dnnClear hcTabPane Hidden">
<div class="dnnFormItem dnnFormRequired">
<label class="dnnLabel">@Localization.GetString("EmailAddress"):</label>
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail)
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail)
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public ActionResult CleanCreditCard()
}

[HccHttpPost]
[ValidateAntiForgeryToken]
public ActionResult IsEmailKnown()
{
var result = new IsEmailKnownJsonModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show().removeClass("d-none");
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'col-12 alert alert-success').slideDown();
Expand All @@ -55,8 +62,8 @@
else {
$('#loginmessage').attr('class', 'alert alert-danger').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@
<div class="form-group row dnnFormRequired">
<label class="col-sm-4 col-form-label" for="customeremail">@Localization.GetString("EmailAddress"):</label>
<div class="col-sm-6 offset-sm-0">
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new {@class = "form-control"})
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new { @class = "form-control" })
}
</div>
</div>
</div>
Expand Down
19 changes: 13 additions & 6 deletions Website/Portals/_default/HotcakesViews/Porto5/Scripts/Checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@

function IsEmailKnown(forceSwitch, emailfieldid) {
var emailfield = $(emailfieldid || '#customeremail').val().toLowerCase();
$.post(hcc.getServiceUrl("checkout/IsEmailKnown"),
{
"email": emailfield
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();

$.ajax({
url: hcc.getServiceUrl("checkout/IsEmailKnown"),
type: 'post',
data: {
email: emailfield,
__RequestVerificationToken: token
},
function (data) {
dataType: 'json',
success: function (data) {
if (data.success == "1") {
$('#hcLoginSection').show().removeClass("d-none");
$('#loginmessage').html(hcc.l10n.checkout_PleaseLogin).attr('class', 'col-12 alert alert-success').slideDown();
Expand All @@ -55,8 +62,8 @@
else {
$('#loginmessage').attr('class', 'alert alert-danger').slideUp();
}
},
"json");
}
});
}

function LoginAjax() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@
<div class="form-group row dnnFormRequired">
<label class="col-sm-4 col-form-label" for="customeremail">@Localization.GetString("EmailAddress"):</label>
<div class="col-sm-6 offset-sm-0">
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new {@class = "form-control"})
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
@Html.TextBox("customeremail", @Model.CurrentOrder.UserEmail, new { @class = "form-control" })
}
</div>
</div>
</div>
Expand Down
Loading