Skip to content

Commit

Permalink
Merge pull request #492 from code4romania/389-general-implement-log-i…
Browse files Browse the repository at this point in the history
…n-error-message-for-a-user-with-statussuspendat

Notification for inactive user
  • Loading branch information
gheorghelupu17 authored Jan 13, 2025
2 parents 53b4451 + 1869821 commit 5f64597
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/Http/Middleware/EnsureUserIsActive.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Models\UserStatus;
use Closure;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -39,7 +40,6 @@ public function handle(Request $request, Closure $next): Response
)
->first();

// dd($activeOrganization);
if ($activeOrganization) {
auth()->user()->update(['latest_organization_id' => $activeOrganization->organization_id]);

Expand All @@ -52,8 +52,16 @@ public function handle(Request $request, Closure $next): Response
$request->session()->invalidate();
$request->session()->regenerateToken();

return redirect()->to(Filament::getCurrentPanel()->getLoginUrl())
->with('error', __('user.inactive_error'));
Notification::make()
->title(__('user.inactive_error.title', [
'seconds' => 10,
]))
->body(\array_key_exists('body', __('user.inactive_error') ?: []) ? __('user.inactive_error.body', [
'seconds' => 10,
]) : null)
->danger()->send();

return redirect()->to(Filament::getCurrentPanel()->getLoginUrl());
}

public function userAndInstitutionIsActive(): bool|RedirectResponse
Expand Down
5 changes: 5 additions & 0 deletions lang/ro/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@
'active' => 'Activ',
'inactive' => 'Inactiv',
],

'inactive_error' => [
'title' => 'Contul tău nu este activ.',
'body' => 'Contul tău nu este activ. Pentru mai multe detalii te rugăm să contactezi un administrator.',
],
];

0 comments on commit 5f64597

Please sign in to comment.