示例#1
0
 public function run()
 {
     $model = new User();
     $model->scenario = User::SCENARIO_UPDATE_USER;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $auth = Yii::$app->authManager;
         $role = $auth->getRole($this->role);
         $auth->assign($role, $model->getId());
         return $this->controller->redirect([$this->redirectAction]);
     } else {
         return $this->controller->render($this->view, ['model' => $model]);
     }
 }
示例#2
0
 public function actionCreateClient()
 {
     $model = new User();
     $model->scenario = User::SCENARIO_CREATE_USER;
     $model->status = User::STATUS_ACTIVE;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $auth = Yii::$app->authManager;
         $role = $auth->getRole('client');
         $auth->assign($role, $model->getId());
         return $this->redirect(['create-client-profile', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }