params['access_token_name']); if(!empty($token)) { $tokenModel = \app\modules\ucenter\models\UserToken::find()->where('token = :token and request_from=:request_from', [':token' => $token,':request_from' => REQUEST_FROM])->orderBy(['create_time'=>SORT_DESC])->one(); if($tokenModel) { $user = \app\modules\ucenter\models\User::find()->where("user_id=".$tokenModel->user_id)->one(); } } else { $user = \app\modules\ucenter\models\User::find()->where("user_id=".Identify::getUserInfo(null,'user_id'))->one(); } if($user&&$user->refreshAccessToken($user,REQUEST_FROM)) { $newTokenModel = \app\modules\ucenter\models\User::getToken($user->user_id,REQUEST_FROM); if($newTokenModel->token!=$token) { \app\common\helpers\Cookie::setCookie(Yii::$app->params['access_token_name'],$newTokenModel->token); } return true; } else { //如果刷新失败,说明是多端登录,清除COOKIE Identify::logout(); \app\common\helpers\Cookie::deleteCookie(Yii::$app->params['access_token_name']); header("Location:".get_url()); return false; } } }