• <legend id='liO7T'><style id='liO7T'><dir id='liO7T'><q id='liO7T'></q></dir></style></legend>

      <tfoot id='liO7T'></tfoot>
        • <bdo id='liO7T'></bdo><ul id='liO7T'></ul>
        <i id='liO7T'><tr id='liO7T'><dt id='liO7T'><q id='liO7T'><span id='liO7T'><b id='liO7T'><form id='liO7T'><ins id='liO7T'></ins><ul id='liO7T'></ul><sub id='liO7T'></sub></form><legend id='liO7T'></legend><bdo id='liO7T'><pre id='liO7T'><center id='liO7T'></center></pre></bdo></b><th id='liO7T'></th></span></q></dt></tr></i><div id='liO7T'><tfoot id='liO7T'></tfoot><dl id='liO7T'><fieldset id='liO7T'></fieldset></dl></div>
      1. <small id='liO7T'></small><noframes id='liO7T'>

        Laravel JWT Auth 在登录时获取用户

        Laravel JWT Auth get user on Login(Laravel JWT Auth 在登录时获取用户)

        <small id='CiJsm'></small><noframes id='CiJsm'>

          <tbody id='CiJsm'></tbody>
      2. <i id='CiJsm'><tr id='CiJsm'><dt id='CiJsm'><q id='CiJsm'><span id='CiJsm'><b id='CiJsm'><form id='CiJsm'><ins id='CiJsm'></ins><ul id='CiJsm'></ul><sub id='CiJsm'></sub></form><legend id='CiJsm'></legend><bdo id='CiJsm'><pre id='CiJsm'><center id='CiJsm'></center></pre></bdo></b><th id='CiJsm'></th></span></q></dt></tr></i><div id='CiJsm'><tfoot id='CiJsm'></tfoot><dl id='CiJsm'><fieldset id='CiJsm'></fieldset></dl></div>

        <legend id='CiJsm'><style id='CiJsm'><dir id='CiJsm'><q id='CiJsm'></q></dir></style></legend>
      3. <tfoot id='CiJsm'></tfoot>

                  <bdo id='CiJsm'></bdo><ul id='CiJsm'></ul>

                  本文介绍了Laravel JWT Auth 在登录时获取用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以使用 https://github.com/tymondesigns/jwt-auth获取当前用户?因为现在我只能生成一个令牌(当用户登录时).

                  Is it possible with https://github.com/tymondesigns/jwt-auth to get the current user? Because right now I can only generate a token (when a user sign in).

                  public function login(Request $request)
                  {
                      $credentials = $request->only('email', 'password');
                  
                      try {
                          if (! $token = JWTAuth::attempt($credentials)) {
                              return response()->json(['error' => 'invalid_credentials'], 401);
                          }
                      } catch (TymonJWTAuthExceptionsJWTException $e) {
                          return response()->json(['error' => 'could_not_create_token'], 500);
                      }
                  
                      return response()->json(compact('token'));
                  }
                  

                  推荐答案

                  可以获取登录的用户数据.

                  You can get logged user data.

                  $credentials = $request->only('code', 'password', 'mobile');
                  try {
                      // verify the credentials and create a token for the user
                      if (! $token = JWTAuth::attempt($credentials)) {
                          return response()->json(['error' => 'invalid_credentials'], 401);
                      }
                  } catch (JWTException $e) {
                      // something went wrong
                      return response()->json(['error' => 'could_not_create_token'], 500);
                  }
                  
                  $currentUser = Auth::user();
                  print_r($currentUser);exit;
                  

                  这篇关于Laravel JWT Auth 在登录时获取用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)
                  • <bdo id='OITPo'></bdo><ul id='OITPo'></ul>

                          <small id='OITPo'></small><noframes id='OITPo'>

                          <i id='OITPo'><tr id='OITPo'><dt id='OITPo'><q id='OITPo'><span id='OITPo'><b id='OITPo'><form id='OITPo'><ins id='OITPo'></ins><ul id='OITPo'></ul><sub id='OITPo'></sub></form><legend id='OITPo'></legend><bdo id='OITPo'><pre id='OITPo'><center id='OITPo'></center></pre></bdo></b><th id='OITPo'></th></span></q></dt></tr></i><div id='OITPo'><tfoot id='OITPo'></tfoot><dl id='OITPo'><fieldset id='OITPo'></fieldset></dl></div>
                            <tbody id='OITPo'></tbody>
                        1. <legend id='OITPo'><style id='OITPo'><dir id='OITPo'><q id='OITPo'></q></dir></style></legend>

                            <tfoot id='OITPo'></tfoot>