禁用Auth::attempt()中的重定向


Disable Redirect in Auth::attempt() Laravel 5.1

我使用Laravel创建REST API。我是在登录API,所以我使用AuthController从Laravel构建它。

但是,当我第一次使用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', 'Auth'AuthController@demo');

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

谢谢

好吧,我知道答案了,但这不是一个优雅的方法。我编辑课程RedirectIfAuthenticated和去除return redirect(/home)handle方法。