Ejemplo n.º 1
0
 public function actionChangepass()
 {
     $model = new ChangeForm();
     if ($model->load(Yii::$app->request->post())) {
         $user = TAccount::findOne(\Yii::$app->user->getId());
         $user->pwd = md5($model->password);
         $save = $user->save(false);
         if ($save) {
             \Yii::$app->session->setFlash('success', 'Thay đổi mật khẩu thành công');
         }
         return $this->refresh();
     }
     return $this->render('changepass', ['model' => $model]);
 }
Ejemplo n.º 2
0
 public function actionUpdate($id = null)
 {
     $model = TAccount::findOne($id);
     $oldPwd = $model->pwd;
     if ($model->load(\Yii::$app->request->post())) {
         if ($model->pwd != $oldPwd) {
             $model->pwd = md5($model->pwd);
         }
         $save = $model->save(false);
         if ($save) {
             return $this->redirect('index');
         }
     }
     return $this->render('update', ['model' => $model]);
 }
Ejemplo n.º 3
0
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->redirect($this->baseUrl . 'index', 302);
     }
     $model = new AuthForm();
     if ($model->load(\Yii::$app->request->post())) {
         $identity = TAccount::findOne(['name' => $model->account, 'pwd' => md5($model->password)]);
         if (!empty($identity)) {
             Yii::$app->user->login($identity);
             return $this->redirect($this->baseUrl . 'index', 302);
         }
     }
     return $this->render('login', ['model' => $model]);
 }