Esempio n. 1
0
	public function loadFromForm($formData)
	{
		if(!empty($formData[$this->name]['is_new']) || (!empty($formData[$this->name]['val']) && $this->isChanged))	//checking checkbox of password changing
		{
			$this->value = AAUserIdentity::hashPassword($formData[$this->name]['val']);
			$this->isChanged = true;
		}
	}
Esempio n. 2
0
	/**
	 * Authenticates the password.
	 * This is the 'authenticate' validator as declared in rules().
	 */
	public function authenticate($attribute=null, $params=null)
	{
		$identity = new AAUserIdentity($this->login, $this->password);
		$identity->authenticate();

		switch($identity->errorCode)
		{
			case AAUserIdentity::ERROR_NONE:
			{
				$duration = $this->rememberMe ? 3600*24*7 : 0; // 30 days
				Yii::app()->user->login($identity, $duration);
				return true;
			}
			case AAUserIdentity::ERROR_USER_DISABLED:
				$this->addError('login', Yii::t('AutoAdmin.errors', 'Sorry, your account is blocked'));
				break;
			default:
				$this->addError('password', Yii::t('AutoAdmin.errors', 'Login or password is incorrect'));
				break;
		}
		return false;
	}