public function login() { if (!$this->hasErrors()) { $user = User::model()->findByAttributes(array('username' => $this->username, 'password' => LoginForm::encrypt($this->password))); if (!$user) { $this->addError('password', 'Incorrect username or password.'); } else { Yii::app()->session['login-user'] = $user; Yii::app()->getController()->redirect(array("site/index")); } } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { LoginForm::checkAdminOrSelf($id); $this->pageTitle = "Update User"; $model = $this->loadModel($id); $this->performAjaxValidation($model); if (isset($_POST['User'])) { $model->attributes = $_POST['User']; if ($model->save()) { $model->password = LoginForm::encrypt($model->password); $model->password_repeat = $model->password; $model->save(); Alert::alertMessage('success', 'Account updated successfully.'); } } $this->render('update', array('model' => $model)); }