如果经过身份验证,重定向到索引

时间:2015-03-16 06:57:34

标签: php laravel-5

我是laravel的新人。 如果记录成功,我想将重定向设置为example.com。 我在RedirectIfAuthenticated

中有变化

public function handle($request, Closure $next)
{
    if ($this->auth->check())
    {
        return new RedirectResponse(url('/home'));
    }

    return $next($request);
}

public function handle($request, Closure $next)
{
    if ($this->auth->check())
    {
        return new RedirectResponse(url('/'));
    }

    return $next($request);
}

它仍然会重定向到example.com/home

有人可以提供帮助吗?

1 个答案:

答案 0 :(得分:0)

为什么不从控制器进行重定向: 我相信你只想重定向用户一次,而不是每当调用auth中间件时。

public function postLogin()
{
    $credentials = [
        'email'    => Input::get('email'),
        'password' => Input::get('password')
    ];

    if (Auth::attempt($credentials, Input::has('remember'))) return redirect(url('/home'));

}
相关问题