Merge pull request #16409 from raisedadead/fix/sign-in-feedback
fix(sign-in): Adds a feedback on sign-in request
This commit is contained in:
@ -34,18 +34,17 @@ block content
|
|||||||
a(href="/deprecated-signin") Or click here if you want to sign in with other options.
|
a(href="/deprecated-signin") Or click here if you want to sign in with other options.
|
||||||
|
|
||||||
script.
|
script.
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
function disableMagicButton (isDisabled) {
|
||||||
function disableMagicButton (isDisabled) {
|
if (isDisabled) {
|
||||||
if (isDisabled) {
|
$('#magic-btn')
|
||||||
$('#magic-btn')
|
.prop('disabled', true)
|
||||||
.html('<span class="fa fa-circle-o-notch fa-spin fa-fw"></span>')
|
.html('<span style="color:#E0E0E0;"><i class="fa fa-circle-o-notch fa-spin fa-fw"></i>Ok - We will attempt sending to the email above.</span>');
|
||||||
.prop('disabled', true);
|
} else {
|
||||||
} else {
|
$('#magic-btn')
|
||||||
$('#magic-btn')
|
.prop('disabled', true)
|
||||||
.html('<span class="fa.fa-envelope">Get a magic link to sign in.</span>')
|
.html('<span style="color:#E0E0E0;">Did not get a link? Reload the page and resend again.</span>');
|
||||||
.prop('disabled', false);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('form').submit(function(event){
|
$('form').submit(function(event){
|
||||||
@ -54,26 +53,29 @@ block content
|
|||||||
disableMagicButton(true);
|
disableMagicButton(true);
|
||||||
var $form = $(event.target);
|
var $form = $(event.target);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'POST',
|
type : 'POST',
|
||||||
url : $form.attr('action'),
|
url : $form.attr('action'),
|
||||||
data : $form.serialize(),
|
data : $form.serialize(),
|
||||||
dataType : 'json',
|
dataType : 'json',
|
||||||
encode : true,
|
encode : true,
|
||||||
xhrFields : { withCredentials: true }
|
xhrFields : { withCredentials: true }
|
||||||
})
|
})
|
||||||
.fail(error => {
|
.fail(error => {
|
||||||
if (error.responseText){
|
if (error.responseText){
|
||||||
var data = JSON.parse(error.responseText);
|
var data = JSON.parse(error.responseText);
|
||||||
if(data.error && data.error.message)
|
if(data.error && data.error.message) {
|
||||||
$('#flash-content').html(data.error.message);
|
$('#flash-content').html(data.error.message);
|
||||||
$('#flash-board')
|
$('#flash-board')
|
||||||
.removeClass('alert-success')
|
.removeClass('alert-success')
|
||||||
.addClass('alert-info')
|
.addClass('alert-info')
|
||||||
|
.slideDown(400)
|
||||||
|
.delay(800)
|
||||||
.fadeIn();
|
.fadeIn();
|
||||||
disableMagicButton(false);
|
disableMagicButton(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.done(data =>{
|
.done(data => {
|
||||||
if(data && data.message) {
|
if(data && data.message) {
|
||||||
var alertType = 'alert-';
|
var alertType = 'alert-';
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
@ -91,11 +93,13 @@ block content
|
|||||||
}
|
}
|
||||||
$('#flash-content').html(data.message);
|
$('#flash-content').html(data.message);
|
||||||
$('#flash-board')
|
$('#flash-board')
|
||||||
.removeClass('alert-info alert-success alert-danger')
|
.removeClass('alert-info alert-success alert-danger')
|
||||||
.addClass(alertType)
|
.addClass(alertType)
|
||||||
.fadeIn();
|
.slideDown(400)
|
||||||
|
.delay(800)
|
||||||
|
.fadeIn();
|
||||||
disableMagicButton(false);
|
disableMagicButton(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user