Skip to content

Commit 3f7ce48

Browse files
author
ahmadhuss
committed
revert: Revert back old logic of RedirectIfAuthenticated route middleware
* We didn't remove the `RedirectIfAuthenticated` middleware instead move the logic into `RedirectIfAuthenticatedOld` middleware.
1 parent 993ffd5 commit 3f7ce48

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

app/Http/Middleware/RedirectIfAuthenticated.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,12 @@ class RedirectIfAuthenticated
1919
*/
2020
public function handle(Request $request, Closure $next, ...$guards)
2121
{
22-
// If you authenticated with the `normal user` then the `SessionGuard` object 'name' will be `null`
23-
// and Auth::guard($guard)->check() will return TRUE
24-
// and invokes the line `redirect(RouteServiceProvider::HOME)`.
2522
$guards = empty($guards) ? [null] : $guards;
26-
27-
// Remember Auth::guard('admin') will returns a `SessionGuard` object
28-
// which will use `check()` method to return boolean Is the Authenticated user is authenticated
29-
// with the `admin` guard session?
3023
foreach ($guards as $guard) {
31-
32-
// At the time of "localhost/admin/login" route the $guard will be `admin` then
33-
// is_null('admin') will return false and we make this expression true. So redirection
34-
// to the dashboard will automatically happen.
35-
36-
// But if guard session is admin & guard is null returns true then we make
37-
// this false and whole expression will not RUN
38-
39-
// Thr expression will only run if there is explicitly guard value is present
40-
if (!is_null($guard) && Auth::guard('admin')->check()) {
41-
return redirect()->route('dashboard');
42-
}
43-
44-
45-
else if (Auth::guard($guard)->check()) {
24+
if (Auth::guard($guard)->check()) {
4625
return redirect(RouteServiceProvider::HOME);
4726
}
4827
}
49-
50-
51-
// If there is not any session guard present in the request. please open the route.
52-
// if (Auth::guard($guard)->check()) returns true then it means the user is
53-
// authenticated with the some session guard, then $next($request) will not work.
5428
return $next($request);
5529
}
5630
}

0 commit comments

Comments
 (0)