Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
24
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Laravel ログイン中、ログイン画面にアクセスした際のリダイレクト先変更

最初に

php artisan make:auth で作成した認証機能である
変更箇所のみ記載、説明なし

目的

  • ログイン後に/homeでなく、/topにリダイレクトしたい
  • ログイン中に/loginにアクセスした際、/topにリダイレクトしたい

app\Http\Middleware\RedirectIfAuthenticated.phpの変更


    public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
-            return redirect('/home');
+            return redirect('/top');
        }

        return $next($request);
    }

app\Http\Controllers\Auth\LoginController.phpの変更

-    protected $redirectTo = '/home';
+    protected $redirectTo = '/top';

その他の変更

  • app\Http\Controllers\Auth\RegisterController.php
  • app\Http\Controllers\Auth\ResetPasswordController.php
-    protected $redirectTo = '/home';
+    protected $redirectTo = '/top';
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
24
Help us understand the problem. What are the problem?