public function actionSelect($app_id, $app_secret) { $session = Yii::$app->session; $model = App::findOne(['app_id' => $app_id, 'app_secret' => $app_secret]); if (!Yii::$app->user->can('app_' . $model->app_code)) { throw new ForbiddenHttpException('没有该项目权限'); } $session['api_url'] = $model->api_url; $session['app_code'] = $model->app_code; $session['app_name'] = $model->app_name; $this->redirect(['main/add']); }
/** * Finds the App model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return App the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = App::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }