Laravel 5.3 custom jump route after successful login is invalid?
某草草
某草草 2017-05-16 16:48:42
0
1
594

https://laravel.com/docs/5.3/...

Said in the official documentation

If the redirect path needs custom generation logic you may define a redirectTo method instead of a redirectTo property:

The following is the code in my LoginController:

<?php

namespace App\Http\Controllers\User\Ui\Auth;

use App\Http\Controllers\Controller as Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Redirect;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
//    protected $redirectTo = '/';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
        config(['app.name' => '点跃']);
    }

    public function index()
    {
        return \Auth::user();
    }

    protected function redirectTo()
    {
        die('ok');
        return Redirect::route('index');
    }
}

But if the login is successful, it will jump to /home

某草草
某草草

reply all(1)
曾经蜡笔没有小新

Just define the attributesredirectTo and that’s it

class LoginController extends Controller
{
    protected $redirectTo = '/index';
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template