<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ? 大前提: 一、在需要獲取用戶信息的接口,前端需要在調用api的時候在頭部傳token,這個token在登錄的時候返回給前端。 二、所有的操作都是基于User用戶表進行的,如果是別的用戶表需要進行相關的改動。改動的地方就兩個文件。API跟Auth這兩個類庫里面進行系列操作即可。 零、終極大招 ~~~ $this->auth->direct($info->id); $info['token']=$this->auth->getToken(); $this->success('登錄成功',$this->auth->getUserinfo()); 這樣就完成了一個賬號的登錄,但是要注意賬號各個參數,比如說status是否是'normal',是否被限制登錄了等等,基本上都可以直接完成登錄 ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") 一、登錄獲取token 如果是走系統默認的User里面的登錄,是沒問題,會給你返回一個token。如果是自定義的登錄也想要token,就需要進行三步。 ①登錄類庫繼承 app\\common\\controller\\API,并且使用 如下方法獲取token ~~~php Api::getRefreshtoken($userid); //這里傳值是傳的user_id ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") ②app\\common\\controller\\Api 里面新增方法: ~~~php /*創建token*/ public function getRefreshtoken($user_id){ return $this->auth->getRefreshtoken($user_id); } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") ③app\\common\\library\\Auth里面新增方法: ~~~php public function getRefreshtoken($user_id){ $this->direct($user_id); return $this->_token; } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") 二、通過有效的token獲取用戶信息 ①繼承 app\\common\\controller\\Api 類,并且在當前類庫里面加上以下代碼: ~~~php protected $noNeedLogin = ['login','test', 'mobilelogin', 'register', 'resetpwd', 'changeemail', 'changemobile', 'third']; protected $noNeedRight = '*'; public function _initialize() { parent::_initialize(); } 測試通過api頭部帶token獲取用戶信息 public function getinfos(){ $info=Api::getUser(); return json($info); } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") ② app\\common\\controller\\API里面添加下面的方法: ~~~php /*獲取用戶信息*/ public function getUser(){ return $this->auth->getUser(); } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") ?
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看