【问题标题】:Laravel Passport: get the authenticated user via api in web routesLaravel Passport:通过网络路由中的 api 获取经过身份验证的用户
【发布时间】:2018-04-19 16:24:11
【问题描述】:

我已经通过护照 API 在我的前端成功地验证了用户。

但是现在我想实现 Laravel 社交名流来将他们的帐户连接/链接到我的应用程序。所以我想在routes/web.php 中获取经过身份验证的用户,因为我把重定向和回调放在那里。

我尝试在routes/web.php 中添加auth:api,但仍然没有成功。

有没有办法在网络路由中获取经过身份验证的用户?或者有没有办法可以将Laravel/socialiteLaravel/Passport 一起使用?

谢谢

【问题讨论】:

    标签: laravel laravel-socialite laravel-passport


    【解决方案1】:

    我知道一种通过这种方法获取经过身份验证的用户的方法:

    Route::get('get/user', function (\Illuminate\Http\Request $request) {
          $user = $request->user();
      });
    

    【讨论】:

    • 嘿,谢谢,但这并没有让经过身份验证的用户获得非身份验证保护的网络路由。
    • 您可以将您正在使用的守卫传递给用户方法。它应该工作。喜欢用户('someguard');
    猜你喜欢
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    • 2018-03-22
    • 2018-07-20
    • 2017-06-19
    • 1970-01-01
    相关资源
    最近更新 更多