Changeset 2058533
- Timestamp:
- 03/27/2019 07:56:14 PM (7 years ago)
- Location:
- cyclos/trunk
- Files:
-
- 3 edited
-
cyclos-common.php (modified) (2 diffs)
-
cyclos-public.php (modified) (8 diffs)
-
stylesheet.css (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cyclos/trunk/cyclos-common.php
r2058400 r2058533 56 56 CyclosKey::add($result, 'errorInaccessibleChannel', 'Error message: inaccessible channel', 'Access denied. The channel used to connect to the server is not allowed or misconfigured'); 57 57 CyclosKey::add($result, 'errorInaccessiblePrincipal', 'Error message: inaccessible principal', 'You cannot use your {principal} in this channel'); 58 CyclosKey::add($result, 'errorIndefinitelyBlocked', 'Error message: password indefinitely blocked', 'Your password has been disabled by exceeding the maximum of tries.\nPlease, contact the administration'); 59 CyclosKey::add($result, 'errorTemporarilyBlocked', 'Error message: password temporarily blocked', 'Your password has been blocked by exceeding the maximum of tries'); 58 CyclosKey::add($result, "errorUserBlocked", 'Error message: user blocked', 'Your access has been blocked. Please, contact the administration.'); 59 CyclosKey::add($result, "errorUserDisabled", 'Error message: user disabled', 'Your user account has been disabled. Please, contact the administration.'); 60 CyclosKey::add($result, "errorUserPending", 'Error message: pending user', 'Your user account is pending for activation. Please, contact the administration for more information.'); 60 61 CyclosKey::add($result, "errorLogin", 'Error message: invalid login', 'Invalid username / password'); 61 CyclosKey::add($result, 'errorInvalidPassword', 'Error message: password invalid', 'The given user / password are incorrect. Please, try again'); 62 CyclosKey::add($result, 'errorPasswordIndefinitelyBlocked', 'Error message: password indefinitely blocked', 'Your password has been disabled by exceeding the maximum of tries.\nPlease, contact the administration'); 63 CyclosKey::add($result, 'errorPasswordTemporarilyBlocked', 'Error message: password temporarily blocked', 'Your password has been blocked by exceeding the maximum of tries'); 64 CyclosKey::add($result, 'errorInvalidPassword', 'Error message: password invalid', 'The given password is incorrect. Please, try again'); 62 65 CyclosKey::add($result, "errorInvalidAccessClient", "Error message: invalid access client", "The current access client is not correctly configured"); 63 66 CyclosKey::add($result, 'errorOperatorWithPendingAgreements', 'Error message: operator pending agreements', 'A required agreement needs to be accepted by your manager before you can login'); … … 157 160 // Likely a connection error (no REST API found) 158 161 $property = 'errorConnection'; 159 } 160 } elseif (property_path_exists($e, 'error->code')) { 162 } 163 } elseif (property_path_exists($e, 'error->code')) { 161 164 // Conflict, forbidden or other errors which contains a 'code' attribute 162 $property = 'error'.ucwords($e->error->code); 165 if($e->error->code = 'login') { 166 // Handle login error 167 if(property_exists($e->error, 'passwordStatus')) { 168 // Password errors 169 $property = 'errorPassword'.ucwords($e->error->passwordStatus); 170 } else if(property_exists($e->error, 'userStatus')) { 171 // User errors 172 $property = 'errorUser'.ucwords($e->error->userStatus); 173 } 174 } 175 if($property == NULL) { 176 $property = 'error'.ucwords($e->error->code); 177 } 163 178 } 164 179 } -
cyclos/trunk/cyclos-public.php
r2058400 r2058533 61 61 $authService = new Cyclos\AuthService(); 62 62 63 $out = ''; 63 $out = '<div id="alert" style="display: none;"> 64 <span class="closebtn" onclick="this.parentElement.style.display=\'none\';">×</span> 65 <strong>Notice</strong> <span id="alertMessage"></span></div>'; 66 64 67 $returnToValue = ''; 65 68 … … 146 149 $out = $out . ' 147 150 <script> 148 jQuery(document).ready(function($) { 151 jQuery(document).ready(function($) { 149 152 '; 150 153 $out = $out . ' 151 $(".cyclosLoginForm").submit(function(event) { 154 155 /** 156 * Shows a notification with type Error, Warning, Info 157 */ 158 function showNotification(message, type) { 159 $("#alertMessage").html(message); 160 $("#alert").show(); 161 $("#alert").attr( "class", "alert"+type); 162 163 164 } 165 166 function hideNotification() { 167 $("#alertMessage").html(""); 168 $("#alert").hide(); 169 } 170 171 $(".cyclosLoginForm").submit(function(event) { 152 172 var submitEnabled = true; 153 173 if (submitEnabled) { 174 hideNotification(); 154 175 var principal = this.cyclosPrincipal.value.trim(); 155 176 var password = this.cyclosPassword.value.trim(); … … 170 191 if (response.redirectUrl) { 171 192 location.href = response.redirectUrl; 172 } else { 173 alert(response.errorMessage || "Invalid data received from server");174 submitEnabled = true;193 } else { 194 showNotification(response.errorMessage || "Invalid data received from server", "Error"); 195 submitEnabled = true; 175 196 } 176 197 }) … … 198 219 function showLogin() { 199 220 if (submitEnabled) { 221 hideNotification(); 200 222 $(".cyclosLoginForm").trigger("reset"); 201 223 $(".cyclosLoginContainer").show(); … … 206 228 207 229 function showForgotPassword() { 208 if (submitEnabled) { 209 $(".cyclosForgotPasswordForm").trigger("reset"); 230 if (submitEnabled) { 231 hideNotification(); 232 $(".cyclosForgotPasswordForm").trigger("reset"); 210 233 $(".cyclosLoginContainer").hide(); 211 234 $(".cyclosForgotContainer").show(); … … 235 258 $(".cyclosForgotPasswordForm").submit(function(event) { 236 259 if (submitEnabled) { 260 261 hideNotification(); 262 237 263 var email = this.cyclosEmail.value.trim(); 238 264 var captchaText = this.cyclosCaptcha.value.trim(); … … 252 278 response = response || {}; 253 279 if (response.errorMessage) { 254 alert(response.errorMessage || "Invalid data received from server");280 showNotification(response.errorMessage || "Invalid data received from server", "Error"); 255 281 } else { 256 282 captchaId = null; 257 283 showLogin(); 258 alert("' . $t->forgotDone . '".replace("{email}", email));284 showNotification("' . $t->forgotDone . '".replace("{email}", email), "Error"); 259 285 } 260 286 }) … … 308 334 sanitize_text_field($_POST['password']), 309 335 $_SERVER['REMOTE_ADDR']); 310 } catch (\Exception $e) { 336 } catch (\Exception $e) { 311 337 $errorMessage = handleError($e); 312 338 } -
cyclos/trunk/stylesheet.css
r2058400 r2058533 51 51 } 52 52 53 .cyclosFormBox a:hover { 53 .cyclosFormBox a:hover, 54 .closebtn:hover { 54 55 color: #9cb7c3; 55 56 } … … 89 90 margin: 7px 0 -5px; 90 91 } 92 93 #alert { 94 padding: 5px 10px; 95 color: #ffffff; 96 width: 250px; 97 margin: auto; 98 font-family: "Open sans",Helvetica,Arial,Verdana,sans-serif; 99 font-size: 15px; 100 position: relative; 101 -webkit-border-radius: 3px; 102 border-radius: 3px; 103 } 104 105 .alertError { 106 background-color: #b00020; 107 } 108 109 #alert strong { 110 display: block; 111 } 112 113 #alertMessage { 114 display: inline-block; 115 line-height: 18px; 116 } 117 118 .closebtn { 119 margin-left: 10px; 120 color: white; 121 font-weight: bold; 122 position: absolute; 123 font-size: 22px; 124 cursor: pointer; 125 transition: 0.3s; 126 vertical-align: middle; 127 line-height: 35px; 128 right: 10px; 129 top: 0px; 130 }
Note: See TracChangeset
for help on using the changeset viewer.