fix(auth): fixing redirectingAuth
This commit is contained in:
parent
7751f8371f
commit
64a65d0c97
|
@ -21,7 +21,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp
|
|||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
return redirect(RouteServiceProvider::home());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -17,7 +18,20 @@ class RouteServiceProvider extends ServiceProvider
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/dashboard';
|
||||
// public const HOME = '/dashboard';
|
||||
public static function home()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user) {
|
||||
return match ($user->role) {
|
||||
'admin' => '/dashboard-admin',
|
||||
'user' => '/dashboard-petugas',
|
||||
};
|
||||
}
|
||||
|
||||
return '/dashboard'; // Default jika tidak ada user (fallback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
|
|
Loading…
Reference in New Issue