Redirect to login page showing error

I'm trying to create a Middleware to validate User Status (When user is logged in and admins change the status to inactive, I have to redirect user to the login page and show a specific error). I can show specific errors on login, but just overriding function throwFailureValidationException from Login and when user is already on login page, but when i am inside system and try to redirect with something like bellow, it not works. (Redirect but doesn't show message error).

throw ValidationException::withMessages([
'data.login' => __('filament-panels::pages/auth/login.messages.failed'),
]);

throw ValidationException::withMessages([
'data.login' => __('filament-panels::pages/auth/login.messages.failed'),
]);
6 Replies
leoblanski
leoblanskiOP14mo ago
More details:
No description
leoblanski
leoblanskiOP14mo ago
When i'm already on Login page, and try to do login with inactive user, show message. When i'm inside other page, and redirect to Login, it not works. If i use the notification like below, it redirects and show notification on login page normally.
Notification::make()
->title(__('Your account is currently inactive!', [
'seconds' => 60,
]))
->body(__('Please get in touch with the systems administrator to reactivate your account.', [
'seconds' => 60,
]))
->danger()
->send();
Notification::make()
->title(__('Your account is currently inactive!', [
'seconds' => 60,
]))
->body(__('Please get in touch with the systems administrator to reactivate your account.', [
'seconds' => 60,
]))
->danger()
->send();
Pasteko
Pasteko13mo ago
Hello, I'm trying to achieve the same result, have you found a solution?
leoblanski
leoblanskiOP13mo ago
Not yet @Pasteko 😦
DrByte
DrByte13mo ago
Is it because the session has lost the message because of the redirect?
leoblanski
leoblanskiOP13mo ago
Yes @DrByte i think so.

Did you find this page helpful?