예제 #1
0
 /**
  * Finds the Applications model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Applications the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Applications::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Refresh app private key
  *
  * <b>Request Type</b>: PUT<br/><br/>
  * <b>Request Endpoint</b>:http://{server-domain}/management/app-key/refresh/{appKeyId}<br/><br/>
  * <b>Content-type</b>: application/json<br/><br/>
  * <b>Summary</b>: This api is used for billing account to refresh app private key
  * <br/><br/>
  *
  * <b>Response Example</b>:<br/>
  * <pre>
  * {
  *    "id": "5524d4ac2736e7f5048b4567",
  *    "name": "爱不宅",
  *    "privateKey": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6InV3aW1zY3Ryb2UifQ.eyJ1aWQiOiI1NGEwZTBkMTI3MzZlN2QyMDQ4YjQ1NjkiLCJzY29wZXMiOltdLCJhcHAiOiI1NTI0ZDRhYzI3MzZlN2Y1MDQ4YjQ1NjcifQ.BRVjkrm7M5speEDhVpCVsIKkJioD8PVcAhxC-Zm9P5g"
  * }
  * </pre>
  */
 public function actionRefresh($id)
 {
     $token = Token::getToken();
     $appId = new \MongoId($id);
     $app = Applications::findByPk($appId);
     if (empty($app)) {
         throw new BadRequestHttpException(Yii::t('common', 'incorrect_appkeyid'));
     }
     $app->generateKey();
     return $app->validateSave();
 }