|
32 | 32 |
|
33 | 33 | // Verifica che sia stata fornita un token |
34 | 34 | if (empty($token)) { |
35 | | - flash()->warning(tr('Token mancante')); |
| 35 | + $_SESSION['login_error'] = tr('Token mancante'); |
36 | 36 | redirect_url(base_path_osm().'/index.php'); |
37 | 37 | exit; |
38 | 38 | } |
|
90 | 90 | exit; |
91 | 91 | } else { |
92 | 92 | // Login fallito, mostra errore e torna al form OTP |
93 | | - flash()->warning($result['message']); |
| 93 | + $_SESSION['login_error'] = $result['message']; |
94 | 94 | redirect_url(base_path_osm().'/token_login.php?token='.urlencode($token_param).'&otp_requested=1'); |
95 | 95 | exit; |
96 | 96 | } |
|
131 | 131 | exit; |
132 | 132 | } else { |
133 | 133 | // Login fallito, mostra errore |
134 | | - flash()->warning($result['message']); |
| 134 | + $_SESSION['login_error'] = $result['message']; |
135 | 135 | redirect_url(base_path_osm().'/index.php'); |
136 | 136 | exit; |
137 | 137 | } |
138 | 138 | } else { |
139 | | - flash()->error(tr('Token non valido')); |
| 139 | + $_SESSION['login_error'] = tr('Token non valido'); |
140 | 140 | redirect_url(base_path_osm().'/index.php'); |
141 | 141 | exit; |
142 | 142 | } |
|
152 | 152 | redirect_url(base_path_osm().'/token_login.php?token='.urlencode($token_param).'&otp_requested=1'); |
153 | 153 | exit; |
154 | 154 | } else { |
155 | | - flash()->error(tr('Token non valido')); |
| 155 | + $_SESSION['login_error'] = tr('Token non valido'); |
156 | 156 | redirect_url(base_path_osm().'/index.php'); |
157 | 157 | exit; |
158 | 158 | } |
|
183 | 183 | 'user_agent' => Filter::getPurifier()->purify($_SERVER['HTTP_USER_AGENT']), |
184 | 184 | ]); |
185 | 185 |
|
186 | | - flash()->warning(tr('Token non valido o non abilitato')); |
| 186 | + $_SESSION['login_error'] = tr('Token non valido o non abilitato'); |
187 | 187 | redirect_url(base_path_osm().'/index.php'); |
188 | 188 | exit; |
189 | 189 | } |
|
209 | 209 | 'user_agent' => Filter::getPurifier()->purify($_SERVER['HTTP_USER_AGENT']), |
210 | 210 | ]); |
211 | 211 |
|
212 | | - flash()->warning(tr('Token non attivo')); |
| 212 | + $_SESSION['login_error'] = tr('Token non attivo'); |
213 | 213 | redirect_url(base_path_osm().'/index.php'); |
214 | 214 | exit; |
215 | 215 | } |
|
227 | 227 | 'user_agent' => Filter::getPurifier()->purify($_SERVER['HTTP_USER_AGENT']), |
228 | 228 | ]); |
229 | 229 |
|
230 | | - flash()->warning(tr('Utente non abilitato')); |
| 230 | + $_SESSION['login_error'] = tr('Utente non abilitato'); |
231 | 231 | redirect_url(base_path_osm().'/index.php'); |
232 | 232 | exit; |
233 | 233 | } |
|
274 | 274 | if (!empty($token_record['id_module_target']) && !empty($token_record['id_record_target'])) { |
275 | 275 | redirect_url(base_path_osm().'/shared_editor.php?id_module='.$token_record['id_module_target'].'&id_record='.$token_record['id_record_target']); |
276 | 276 | } else { |
277 | | - flash()->warning(tr('Token non configurato correttamente per l\'accesso diretto')); |
| 277 | + $_SESSION['login_error'] = tr('Token non configurato correttamente per l\'accesso diretto'); |
278 | 278 | redirect_url(base_path_osm().'/index.php'); |
279 | 279 | } |
280 | 280 | } |
281 | 281 | exit; |
282 | 282 | } else { |
283 | | - flash()->warning($result['message']); |
| 283 | + $_SESSION['login_error'] = $result['message']; |
284 | 284 | redirect_url(base_path_osm().'/index.php'); |
285 | 285 | exit; |
286 | 286 | } |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } catch (Exception $e) { |
332 | | - flash()->error(tr('Errore durante l\'invio dell\'email OTP: _MSG_', [ |
| 332 | + $_SESSION['login_error'] = tr('Errore durante l\'invio dell\'email OTP: _MSG_', [ |
333 | 333 | '_MSG_' => $e->getMessage(), |
334 | | - ])); |
| 334 | + ]); |
335 | 335 | redirect_url(base_path_osm().'/token_login.php?token='.urlencode($token)); |
336 | 336 | exit; |
337 | 337 | } |
|
368 | 368 |
|
369 | 369 | include_once App::filepath('include|custom|', 'top.php'); |
370 | 370 |
|
| 371 | +// Recupera il messaggio di errore dalla variabile di sessione |
| 372 | +$error_message = $_SESSION['login_error'] ?? null; |
| 373 | +if (!empty($error_message)) { |
| 374 | + // Rimuovi il messaggio dalla sessione dopo averlo recuperato |
| 375 | + unset($_SESSION['login_error']); |
| 376 | + |
| 377 | + echo ' |
| 378 | + <script> |
| 379 | + $(document).ready(function(){ |
| 380 | + // Add shake animation to login box |
| 381 | + $(".login-box").addClass("animated shake"); |
| 382 | +
|
| 383 | + // Add error styling to input field |
| 384 | + if ($("input[name=otp_code]").length > 0) { |
| 385 | + $("input[name=otp_code]").addClass("is-invalid"); |
| 386 | + |
| 387 | + // Add error message under OTP field |
| 388 | + $("input[name=otp_code]").parent().append(\'<div class="invalid-feedback d-block"><i class="fa fa-exclamation-circle mr-1"></i>'.addslashes($error_message).'</div>\'); |
| 389 | + |
| 390 | + // Focus on OTP field |
| 391 | + $("input[name=otp_code]").focus(); |
| 392 | + } else if ($("input[name=password]").length > 0) { |
| 393 | + $("input[name=password]").addClass("is-invalid"); |
| 394 | + |
| 395 | + // Add error message under password field |
| 396 | + $(".password-field-container").append(\'<div class="invalid-feedback d-block"><i class="fa fa-exclamation-circle mr-1"></i>'.addslashes($error_message).'</div>\'); |
| 397 | + |
| 398 | + // Focus on password field |
| 399 | + $("input[name=password]").focus(); |
| 400 | + } |
| 401 | +
|
| 402 | + // Remove error styling when user starts typing |
| 403 | + $("input[name=otp_code], input[name=password]").on("keydown", function() { |
| 404 | + $(this).removeClass("is-invalid"); |
| 405 | + $(".invalid-feedback").fadeOut(300); |
| 406 | + }); |
| 407 | + }); |
| 408 | + </script>'; |
| 409 | +} |
| 410 | + |
371 | 411 | // Controllo se è una beta e in caso mostro un warning |
372 | 412 | if (Update::isBeta()) { |
373 | 413 | echo ' |
|
0 commit comments