This repository has been archived on 2024-12-01. You can view files and clone it, but cannot push or open issues or pull requests.
factuges_web/www/protected/modules/yii-user-master/models/UserChangePassword.php
david e93adbdd4e - Importación inicial
- Registro, activación y entrada de usuarios


git-svn-id: https://192.168.0.254/svn/Rodax.factuges_web/trunk@2 e455b18d-f7fe-5245-9c43-e2c35af70a32
2013-06-13 16:04:48 +00:00

45 lines
1.7 KiB
PHP

<?php
/**
* UserChangePassword class.
* UserChangePassword is the data structure for keeping
* user change password form data. It is used by the 'changepassword' action of 'UserController'.
*/
class UserChangePassword extends CFormModel {
public $oldPassword;
public $password;
public $verifyPassword;
public function rules() {
return Yii::app()->controller->id == 'recovery' ? array(
array('password, verifyPassword', 'required'),
array('password, verifyPassword', 'length', 'max'=>128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'message' => UserModule::t("Retype Password is incorrect.")),
) : array(
array('oldPassword, password, verifyPassword', 'required'),
array('oldPassword, password, verifyPassword', 'length', 'max'=>128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'message' => UserModule::t("Retype Password is incorrect.")),
array('oldPassword', 'verifyOldPassword'),
);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'oldPassword'=>UserModule::t("Old Password"),
'password'=>UserModule::t("password"),
'verifyPassword'=>UserModule::t("Retype Password"),
);
}
/**
* Verify Old Password
*/
public function verifyOldPassword($attribute, $params)
{
if (User::model()->notsafe()->findByPk(Yii::app()->user->id)->password != Yii::app()->getModule('user')->encrypting($this->$attribute))
$this->addError($attribute, UserModule::t("Old Password is incorrect."));
}
}