Пример #1
0
 /**
  * Refresh Token
  *
  * <b>Request Type </b>:GET
  * <b>Request Endpoints </b>: http://{server-domain}/api/site/refresh-token
  * <b>Content-type</b>: application/json<br/><br/>
  * <b>Summary</b>: This api is used for refresh-token.
  *
  * <b>Request Example </b>:
  * <pre>
  *  http://{server-domain}/api/site/refresh-token
  * </pre>
  *
  **/
 public function actionRefreshToken()
 {
     $accesstoken = $this->getAccessToken();
     if (empty($accesstoken)) {
         $accesstoken = $this->getQuery('accesstoken');
     }
     $token = Token::getByAccesstoken($accesstoken);
     if (!empty($token)) {
         $token->expireTime = new \MongoDate(time() + Token::EXPIRE_TIME);
         if ($token->save(true, ['expireTime'])) {
             return ['accessToken' => $token->accessToken];
         } else {
             throw new ServerErrorHttpException('Fail to refresh token');
         }
     } else {
         throw new BadRequestHttpException('Error accesstoken');
     }
 }