Exemplo n.º 1
0
 public function beforeAction($action)
 {
     $_token = \yii::$app->request->post_get('token');
     //判断token是否合法
     $user_id = TokenService::getService()->getIdByToken($_token);
     if (is_int($user_id) && $user_id < 0) {
         exit(\common\helpers\JsonHelper::returnError($user_id));
     }
     $_POST['data']['user_id'] = $user_id;
     return true;
 }
Exemplo n.º 2
0
 public function beforeAction($action)
 {
     $_token = \yii::$app->request->post_get(CommonConstant::TOKEN_NAME);
     //ÅжÏtokenÊÇ·ñºÏ·¨
     $user_id = TokenService::getService()->getIdByToken($_token);
     if (is_numeric($user_id) && $user_id > 0) {
         $_POST[CommonConstant::REQUEST_PARAM]['user_id'] = $user_id;
     } else {
         $_POST[CommonConstant::REQUEST_PARAM]['user_id'] = null;
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * 获取token
  * @param int $user_id
  * @return mixed
  * @deprecate 具有代码冗余的嫌疑 暂时先不用
  */
 private function _buildToken($user_id)
 {
     return TokenService::getService()->createToken($user_id);
 }