jQuery(document).ready(function (){ jQuery('.btn-login').click(function (){ jQuery('#loginModal').modal('show'); }); jQuery('#forgot-password').click(function (){ jQuery('#loginModal').modal('hide'); jQuery('#forgotpassModal').modal('show'); }); jQuery('#login-forms').on('submit', function(e) { jQuery(this).find('button').html('Logging In...Please wait...'); jQuery('#loginMsg').html(''); e.preventDefault(); var $frm = jQuery(this); jQuery.ajax({ method: 'POST', url: routes.login_submit, data: $frm.serialize(), beforeSend: function() { // setting a timeout // jQuery('#verifyButtonText').prop('disabled', true); }, success: function(data){ console.log(data) if(data.result != 'ok' ){ jQuery('#loginMsg').html('
'+data.message+'
'); }else{ var $alert = jQuery('
', { 'class': 'alert alert-success', 'text': 'Redirecting...' }); jQuery('#loginMsg').html($alert); //window.location.href = "https://app.askallyn.com/redirect/"+data.email+'/'+data.pass; app_url = routes.app_url; app_url = app_url.replace(/\/$/, ""); window.location.href = app_url+'/direct-login/?email=' +encodeURIComponent(data.email)+'&password='+data.pass; } } }); }); jQuery('#forgot-password-form').on('submit', function(e) { jQuery(this).find('button').html('Submitting...Please wait...'); jQuery('#forgotPassMsg').html(''); e.preventDefault(); var $frm = jQuery(this); jQuery.ajax({ method: 'POST', url: routes.forgot_password, data: $frm.serialize(), beforeSend: function() { // setting a timeout // jQuery('#verifyButtonText').prop('disabled', true); }, success: function(data){ console.log(data) if(data.result == 'error' ){ jQuery('#forgotPassMsg').html('
'+data.messages[0]+'
'); }else{ var html = '
Reset password sent. Please check your email for the reset password link
'; html += 'Continue'; $frm.html(html); } } }); }); jQuery('#reset-password-form').on('submit', function(e) { e.preventDefault(); var $frm = jQuery(this); jQuery(this).find('button').html('Submitting...Please wait...'); jQuery('#resetPassMsg').html(''); jQuery.ajax({ method: 'POST', url: routes.reset_password, data: $frm.serialize(), beforeSend: function() { // setting a timeout // jQuery('#verifyButtonText').prop('disabled', true); }, success: function(data){ console.log(data) if(data.result == 'error' ){ jQuery('#resetPassMsg').html('
'+data.messages[0]+'
'); }else{ var html = '
Your password has been reset successfully.
'; html += 'Continue'; $frm.html(html); setTimeout(function (){ window.location = "https://www.reviewtrust.com"; },5000); } } }); }); jQuery('#resetpassModal').modal({backdrop: 'static', keyboard: false}) ; jQuery('#resetpassModal').modal('show'); });