1var notificationRedirect = ""; 2const loginForm = document.querySelector('.login-form'); 3const LOGGING_IN = 1; 4const LOGGING_OUT = 2; 5 6if (loginForm) { 7 loginForm.addEventListener('submit', handleSubmit); 8 const logout = loginForm.querySelector('.login-form__logout'); 9 logout && logout.addEventListener('click', handleLogout); 10} 11 12function isNullOrWhitespace(s) { 13 if (typeof s === undefined 14 || s == null 15 || s.replace(/s/g, '').length == 0) { 16 return true; 17 } 18 else { 19 return false; 20 } 21} 22 23function clearLoginErrorMessage() { 24 displayLoginErrorMessage(''); 25} 26 27function displayLoginErrorMessage(s) { 28 const loginError = document.querySelector('.login-form__error'); 29 const tmp = document.createElement("textarea"); 30 tmp.innerHTML = s; 31 loginError.innerHTML = tmp.value; 32 tmp.remove(); 33} 34 35function handleSubmit(evt) { 36 evt.preventDefault(); 37 clearLoginErrorMessage(); 38 setFormLoading(LOGGING_IN); 39 40 var user_name = document.getElementById('login-form__username').value; 41 const username = encodeURIComponent(user_name); 42 var pass_word = document.getElementById('login-form__password').value; 43 var password = encodeURIComponent(pass_word); 44 45 let urlParams = ''; 46 if (typeof URLSearchParams !== 'undefined') { 47 urlParams = new URLSearchParams(window.location.search); 48 } 49 const redirect = typeof(pvRedirect) != 'undefined' ? pvRedirect : (urlParams && urlParams.get('redirect')) || getUrlParameter('redirect'); 50 51 if (isNullOrWhitespace(username)) { 52 displayLoginErrorMessage(errorMessages[ACTION_NOTIFY_OF_MISSING_USER_NAME]); 53 document.getElementById('login-form__username').focus(); 54 return; 55 } 56 else if (isNullOrWhitespace(password)) { 57 displayLoginErrorMessage(errorMessages[ACTION_NOTIFY_OF_MISSING_PASSWORD]); 58 document.getElementById('login-form__password').focus(); 59 return; 60 } 61 62 fetch(loginForm.getAttribute('action'), { 63 method: 'POST', 64 mode: 'cors', 65 credentials: 'include', 66 cache: 'no-cache', 67 headers: { 68 'Content-Type': 'application/x-www-form-urlencoded' 69 }, 70 body: "username=" + username + "&password=" + password + "&redirect=" + redirect 71 }) 72 .then(function (response) { 73 if (response.ok) { 74 return response.json(); 75 } else { 76 handleError(); 77 } 78 }) 79 .then(handleResponse) 80 .catch(handleError); 81 82 return false; 83} 84 85function handleResponse(data) { 86 if (data.success) { 87 88 if (window.location.search.includes("pv=")) { 89 document.querySelectorAll(`.login-form__submit`).forEach((el) => { 90 const successMessage = document.createElement('div'); 91 successMessage.style = 'text-align: center; color: #34C759; font-weight:600'; 92 successMessage.textContent = `Sign in successful! Navigating to Candidate Dashboard...`; 93 el.replaceWith(successMessage); 94 }); 95 } 96 97 //Set cookies 98 document.cookie = "kentico-NREMTsessionAccountId=" + data.userId + ";path=/"; 99 document.cookie = "kentico-NREMTidentity=" + data.token + ";path=/"; 100 document.cookie = "kentico-NREMTroles=" + data.permissions + ";path=/"; 101 document.cookie = "kentico-NREMTrights=" + data.rights + ";path=/"; 102 document.cookie = "kentico-NREMTcurrentUserName=" + data.name + ";path=/"; 103 document.cookie = "kentico-NREMThomePage=" + data.homePage + ";path=/"; 104 document.cookie = "kentico-NREMTsessionTimeout=" + data.sessionTimeout + ";path=/"; 105 if (data.displayNotification) { 106 // nothing? 107 } else { 108 //Set cookies 109 document.cookie = "kentico-NREMTsessionAccountId=" + data.userId + ";path=/"; 110 document.cookie = "kentico-NREMTidentity=" + data.token + ";path=/"; 111 document.cookie = "kentico-NREMTroles=" + data.permissions + ";path=/"; 112 document.cookie = "kentico-NREMTrights=" + data.rights + ";path=/"; 113 document.cookie = "kentico-NREMTcurrentUserName=" + data.name + ";path=/"; 114 document.cookie = "kentico-NREMThomePage=" + data.homePage
114+ ";path=/"; 115 document.cookie = "kentico-NREMTsessionTimeout=" + data.sessionTimeout + ";path=/"; 116 117 if (location.pathname.indexOf('/store') == 0) { 118 location.reload(); 119 return; 120 } 121 if (data.redirect) { 122 location.href = "/login/landing?redirect=" + data.redirect; 123 } else { 124 location.reload(); 125 } 126 return; 127 } 128 } 129 else { 130 var messageId = ACTION_SHOW_INTERNAL_ERROR_MESSAGE; 131 132 switch (data.code) { 133 case ACTION_NOTIFY_USER_OF_LOCKOUT: 134 var message = errorMessages[data.code]; 135 message = message.replace("{MINUTES_REMAINING}", data.minutes); 136 displayLoginErrorMessage(message); 137 break; 138 139 case ACTION_SHOW_INVALID_LOGIN_MESSAGE: 140 messageId = data.code; 141 142 case ACTION_SHOW_INTERNAL_ERROR_MESSAGE: 143 default: 144 displayLoginErrorMessage(errorMessages[messageId]); 145 break; 146 } 147 } 148 setFormLoading(0); 149} 150 151function getExpiration(token) { 152 if (token) { 153 try { 154 const [, payload] = token.split('.'); 155 const { exp: expires } = JSON.parse(window.atob(payload)); 156 if (typeof expires === 'number') { 157 return new Date(expires * 1000); 158 } 159 } catch (err) { 160 console.log(err) 161 } 162 } 163 return null; 164} 165 166function handleError() { 167 setFormLoading(0); 168 169 displayLoginErrorMessage(errorMessages[ACTION_SHOW_INTERNAL_ERROR_MESSAGE]); 170} 171 172function handleLogout() { 173 setFormLoading(LOGGING_OUT); 174} 175 176function setFormLoading(status) { 177 var form = document.querySelector('.login-form'); 178 switch (status) { 179 case LOGGING_IN: 180 form.classList.add('login-form--logging-in'); 181 break; 182 case LOGGING_OUT: 183 form.classList.add('login-form--logging-out'); 184 break; 185 default: 186 form.classList.remove('login-form--logging-in', 'login-form--logging-out'); 187 } 188} 189 190function getUrlParameter(name) { 191 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); 192 var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); 193 var results = regex.exec(location.search); 194 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); 195}; 196 197// login form password reveal 198const revealPasswordIcon = document.querySelector('.login-form__reveal-password-label'); 199revealPasswordIcon && revealPasswordIcon.addEventListener('click', function () { 200 this.innerHTML = this.querySelectorAll('.bxs-show').length ? '<i class="bx bxs-hide" ></i>' : '<i class="bx bxs-show"></i>'; 201 document.getElementById('login-form__password').setAttribute('type', this.querySelectorAll('.bxs-show').length ? 'password' : 'text'); 202}); 203 204// enums 205var ACTION_NOTIFY_OF_MISSING_USER_NAME = -1; 206var ACTION_NOTIFY_OF_MISSING_PASSWORD = -2; 207var ACTION_NONE = 0; 208var ACTION_REDIRECT_TO_SPECIFIED_PAGE = 1; 209var ACTION_REDIRECT_TO_HOME_PAGE = 2; 210var ACTION_ENTER_DEMOGRAPHICS = 3; 211var ACTION_CHANGE_PASSWORD = 4; 212var ACTION_SHOW_INVALID_LOGIN_MESSAGE = 5; 213var ACTION_SHOW_INTERNAL_ERROR_MESSAGE = 6; 214var ACTION_NOTIFY_USER_OF_LOCKOUT = 7; 215var ACTION_REDIRECT_TO_ACCOUNT_CREATION = 8; 216 217var errorMessages = []; 218errorMessages[ACTION_NOTIFY_OF_MISSING_USER_NAME] = resourceStrings.LoginNotifyOfMissingUserName; 219errorMessages[ACTION_NOTIFY_OF_MISSING_PASSWORD] = resourceStrings.LoginNotifyOfMissingPassword; 220errorMessages[ACTION_SHOW_INVALID_LOGIN_MESSAGE] = resourceStrings.LoginShowInvalidLoginMessage; 221errorMessages[ACTION_SHOW_INTERNAL_ERROR_MESSAGE] = resourceStrings.LoginShowInternalErrorMessage; 222errorMessages[ACTION_NOTIFY_USER_OF_LOCKOUT] = resourceStrings.LoginNotifyUserOfLockout;
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.