Merge pull request #17 from arieeefajar/fix/auth
fix(auth): fixing redirectingAuth
This commit is contained in:
commit
1164c10bb6
|
@ -21,7 +21,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp
|
||||||
|
|
||||||
foreach ($guards as $guard) {
|
foreach ($guards as $guard) {
|
||||||
if (Auth::guard($guard)->check()) {
|
if (Auth::guard($guard)->check()) {
|
||||||
return redirect(RouteServiceProvider::HOME);
|
return redirect(RouteServiceProvider::home());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\RateLimiter;
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class RouteServiceProvider extends ServiceProvider
|
class RouteServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -17,7 +18,20 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
*
|
*
|
||||||
* @var string
|
* @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.
|
* Define your route model bindings, pattern filters, and other route configuration.
|
||||||
|
|
Loading…
Reference in New Issue