加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – 在Auth :: attempt()Laravel 5.1中禁用重定向

发布时间:2020-12-14 19:39:17 所属栏目:大数据 来源:网络整理
导读:我使用Laravel创建REST API.我是在登录API,所以我使用从Laravel构建它的AuthController. 但是,当我在第一次成功获取用户信息时使用Auth :: attempt()验证用户登录时,我调用此方法Auth :: user(). 但是,当我第二次再次运行时,我得到以下错误: NotFoundHttpEx
我使用Laravel创建REST API.我是在登录API,所以我使用从Laravel构建它的AuthController.

但是,当我在第一次成功获取用户信息时使用Auth :: attempt()验证用户登录时,我调用此方法Auth :: user().
但是,当我第二次再次运行时,我得到以下错误:

NotFoundHttpException in RouteCollection.php line 161:

我知道如果用户已经过身份验证,它会自动发送重定向.并保存会话.

这是我在AuthController.php中的登录代码

public function demo() {

        if (Auth::attempt(Input::only('email','password'))) {
            return Auth::user();
        } else {
            return "false";
        }
    }

我写这样的路线:

Route::post('demo','AuthAuthController@demo');

在这种情况下如何禁用重定向?
因为我想从我的移动应用程序调用我的API.

谢谢

解决方法

Answer

Okay i get the solution,but it’s not elegant way. I edit the class
RedirectIfAuthenticated and remove return redirect(/home) in
handle method.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读