1///<reference path="../../jquery-1.10.2.intellisense.js" /> 2///<reference path="Global.js" /> 3 4$(function () { 5 6 $('a.sign-in, #lnk_return_sign_in').on('click', modalLoginOpen); 7 $('#btn_login').data('loading-plugin', $('#btn_login').button({ loadingText: 'Checking <i class="icon-spinner"></i>' })); 8 $('#btn_login').on('click', login); 9 10 $('#login_username, #login_password').on('keydown', function (e) { 11 if (e.keyCode == 13) { 12 if ($(this).prop('id') == 'login_username') { 13 $('#login_password').val('').focus(); 14 } 15 if ($(this).prop('id') == 'login_password') { 16 login(); 17 } 18 19 return false; 20 } 21 }); 22 23 $('#link_forgot_pw').on('click', function () { 24 modalCloseAll(); 25 $('[data-modal="forgot-pw"] .modal-message').hide(); 26 $('[data-modal="forgot-pw"] input').val(''); 27 modalOpen('forgot-pw'); 28 $('[data-modal="forgot-pw"] input').focus(); 29 return false; 30 }); 31 32 $("#email_submit").on('click', checkEmail); 33 34 var qp = queryParams(); 35 if (qp['ReturnUrl']) { 36 modalOpen('please-sign-in'); 37 } 38 39 $('div#login_message').on('click', 'button.verify-email-button', resendVerificationEmail); 40}); 41 42function modalLoginOpen() { 43 modalCloseAll(); 44 $('#login_username, #login_password').val(''); 45 $('#login_message').hide(); 46 modalOpen('sign-in'); 47 $('#login_username').focus(); 48 return false; 49} 50 51function resendVerificationEmail() { 52 $('div#login_message button.verify-email-button').data('loading-plugin', $('div#login_message button.verify-email-button').button({ loadingText: 'Sending <i class="icon-spinner"></i>' })); 53 $('div#login_message button.verify-email-button').data('loading-plugin').loading(true); 54 $.ajax({
55 type: 'POST', 56 url: '/api/User/ResendVerificationLink/', 57 data: { user_name: $('#login_username').val() }, 58 success: function () { 59 $('div#login_message button.verify-email-button').data('loading-plugin').loading(false); 60 $('#login_message').css('background-color', '').html('A new verfication email has been sent to the email provided.'); 61 }, 62 error: function () { 63 $('div#login_message button.verify-email-button').data('loading-plugin').loading(false); 64 displayErrorMessage('Network or Server Error'); 65 } 66 }); 67} 68 69 70function login() { 71 72 $("#login_message").css('background-color', '').hide(); 73 $('#btn_login').data('loading-plugin').loading(true); 74 75 $.ajax({ 76 type: 'POST', 77 url: '/api/Security/Login', 78 data: { userName: $('#login_username').val(), password: $('#login_password').val() }, 79 success: function (msg) { 80 $('#btn_login').data('loading-plugin').loading(false); 81 if (msg.Success) { 82 modalCloseAll(); 83 var qp = queryParams(); 84 if (qp['ReturnUrl']) { 85 $('#redirect_overlay').addClass('active'); 86 window.location.href = decodeURIComponent(qp['ReturnUrl']); 87 } 88 else { 89 window.username = msg.Data.user_name; 90 window.account_links = msg.Data.account_links; 91 window.permission_hashes = msg.Data.permission_hashes; 92 window.favorite_ids = msg.Data.favorite_ids; 93 $(document).trigger('sscevent:asynclogin', [msg.Data.user_name]); 94 } 95 } 96 else if (msg.ErrorCode == "Unverified") { 97 $("#login_message").html('<p>You have not yet verified your <strong>email</strong>.</p><p>Please look for an email from:</p><p style="text-align:center;"><strong>[email protected]</strong></p><p>Donât forget to check your junk/spam folder.</p><button class="btn btn-light-gray btn-block btn-flat btn-extra-padding verify-email-button"> Resend Verification Email <i class="icon-mail_outline"></i></button>').css('background-color', 'pink').show(); 98 } 99 else { 100 $("#login_message").html('Login Failed:\n\n' + msg.Msg).show(); 101 } 102 103 }, 104 error: function () { 105 $('#btn_login').data('loading-plugin').loading(false); 106 $("#login_message").html('Network or Server Error Attempting to Login! Please try again.').show(); 107 } 108 }); 109 110 return false; 111} 112 113function checkEmail() { 114 115 var email = $("#email_input").val(); 116 var email_address_verify = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 117 118 if (!email_address_verify.test(email)) { 119 $("#validate_email").html("Please provide a valid email address.").show(); 120 } 121 else { 122 $.ajax({
123 type: 'POST', 124 url: '/api/Security/ForgotPassword', 125 data: { email: $('#email_input').val() }, 126 success: function (msg) { 127 if (msg.Success) { 128 $("#validate_email").hide(); 129 $("#success_email").hide(); 130 $("#success_email").html("A password reset link has been sent to the provided email address (if they are an active user). Please check your email. If you do not receive an email within 30 minutes, check your SPAM/junk folder or contact a site administrator for assistance.").show(); 131 132 window.setTimeout(function () { 133 modalCloseAll(); 134 }, 8000); 135 } 136 else { 137 $("#validate_email").html(msg.Msg).show(); 138 } 139 }, 140 error: function () { 141 $("#validate_email").html("Unable to generate password link due to network error, please contact your administrator.").show(); 142 } 143 }); 144 } 145 146 return false; 147} 148 149function showInactivityLogin() 150{ 151 modalLoginOpen(); 152 $('#login_message').css('background-color', '').html('You have been logged out due to inactivity, please log back in to proceed.'); 153 window.setTimeout(function () { $('#login_message').show(); }, 500); 154} 155 156
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.