Пример #1
0
 public function actionIndex()
 {
     // create instance of app\models\AuthForm
     $model = new AuthForm();
     // Load data to the model for server side validation
     $model->load(\Yii::$app->request->post());
     if ($model->validate()) {
         print "validated " . $model->username . ' ' . $model->password;
     } else {
         print "not validated";
     }
     // push the model instance to the view
     return $this->render('index', ['model' => $model]);
 }
Пример #2
0
 public function actionAuth()
 {
     $model = new AuthForm();
     $error = null;
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $login = Html::encode($model->login);
         $password = md5($model->password);
         $uc = new UserClass();
         if ($uc->login($login, $password)) {
             return $this->render('account');
         } else {
             $error = 'Неверный логин или пароль, повторите попытку';
         }
     }
     return $this->render('auth', ['model' => $model, 'error' => $error]);
 }
Пример #3
0
 public function actionAuth()
 {
     $model = new AuthForm();
     if ($model->load(Yii::$app->request->post())) {
         $id = $model->auth();
         if ($id) {
             Yii::$app->session->set('patient_id', $id);
             return $this->redirect('index');
         }
     }
     return $this->redirect('/customer-report/index');
 }