Skip to content

Commit

Permalink
Merge pull request #318 from HotcakesCommerce/Bugs/LoginIssueFix
Browse files Browse the repository at this point in the history
Bug Fix for API timeout
  • Loading branch information
Will Strohl authored Oct 12, 2020
2 parents aaae3ee + 344c485 commit 8b4cfe7
Show file tree
Hide file tree
Showing 23 changed files with 202 additions and 80 deletions.
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

0 comments on commit 8b4cfe7

Please sign in to comment.