Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重定向到登录Laravel 5.4之前的视图_Php_Laravel_Authentication - Fatal编程技术网

Php 重定向到登录Laravel 5.4之前的视图

Php 重定向到登录Laravel 5.4之前的视图,php,laravel,authentication,Php,Laravel,Authentication,如何将试图登录到另一个视图的用户重定向到另一个视图,以便为身份验证添加额外的步骤 我在AuthenticateUsers.php中尝试了这个 public function login(Request $request) { $this->validateLogin($request); // If the class is using the ThrottlesLogins trait, we can automatically throttle

如何将试图登录到另一个视图的用户重定向到另一个视图,以便为身份验证添加额外的步骤

我在AuthenticateUsers.php中尝试了这个

public function login(Request $request)
    {
        $this->validateLogin($request);

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if ($this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        if ($this->attemptLogin($request)) {
            //return $this->sendLoginResponse($request);
            return redirect('/auth/'.Auth::id());
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);

        return $this->sendFailedLoginResponse($request);
    }

我试图让它在登录之前显示“/auth/”视图,它确实显示了视图,但它仍然让我登录。

您在
尝试登录()之后设置了重定向。

这段代码的意思是,“如果用户成功登录,请将其重定向到'/auth/$id'。这就是为什么在重定向时您总是登录区域

将重定向放在该行之前

return redirect('/auth/'.Auth::id());
if ($this->attemptLogin($request)) {
    //do stuff
}
但是现在,您将永远无法登录,因为您总是在登录之前返回

我建议您使用手动身份验证。您可以在此处找到帮助:


您在
attemptLogin()之后设置重定向

这段代码的意思是,“如果用户成功登录,请将其重定向到'/auth/$id'。这就是为什么当你被重定向时,你总是登录这个区域

将重定向放在该行之前

return redirect('/auth/'.Auth::id());
if ($this->attemptLogin($request)) {
    //do stuff
}
但是现在,您将永远无法登录,因为您总是在登录之前返回

我建议您使用手动身份验证。您可以在此处找到帮助:



您是否尝试从路由中删除身份验证中间件?我的路由中没有身份验证中间件<代码>路由::get('/auth/{id}','AuthController@index');您可以显示希望用户首先访问的路由吗?
route::get('/auth/{id}','AuthController@index');这是我希望人们在按下“登录”后要去的路线。它确实可以工作,但我也会登录,我只希望在重定向到“/auth”后登录,然后让他们在输入字段中放入随机字符串(他们从电子邮件中获取)然后,当他们按下“验证”键时login@lewis4u这不是我遇到的问题..您是否尝试从路由中删除身份验证中间件?我的路由中没有身份验证中间件<代码>路由::get('/auth/{id}','AuthController@index');您可以显示希望用户首先访问的路由吗?
route::get('/auth/{id}','AuthController@index');这是我希望人们在按下“登录”后要去的路线。它确实可以工作,但我也会登录,我只希望在重定向到“/auth”后登录,然后让他们在输入字段中放入随机字符串(他们从电子邮件中获得),然后当他们按下“验证”时,他们会进行验证login@lewis4u这不是我遇到的问题..如果我将重定向放在attemptLogin之前,当我首先按login时,它不会重定向我,我希望能够在用户单击login时重定向用户,然后向他们显示身份验证表单,然后在正确填写表单后登录。您不能这样做。一旦通过
attempLogin()
,您就已经连接好了。对不起,这太奇怪了,没有办法这么做吗?有。我在回答时是这样说的。您必须进行手动身份验证。我甚至给了你一些链接。但你可以在谷歌上搜索moreAh,好吧!谢谢你,我会尝试解决这个问题的,哈哈,如果我把重定向放在尝试登录之前,当我首先按login时它不会重定向我,我想在用户单击login时能够重定向用户,然后向他们显示一个身份验证表,然后在正确填写后登录。你不能这样做。一旦通过
attempLogin()
,您就已经连接好了。对不起,这太奇怪了,没有办法这么做吗?有。我在回答时是这样说的。您必须进行手动身份验证。我甚至给了你一些链接。但你可以在谷歌上搜索moreAh,好吧!谢谢你,我会想办法的哈哈