How To Add Error Msg In Login Page

I would like to check access time before login if out of time then show error massage

LoginForm.php


	public function authenticate($attribute,$params)

	{

		if(!$this->hasErrors())

		{

			$this->_identity=new UserIdentity($this->username,$this->password);

			if(!$this->_identity->authenticate()){

				$this->addError('password','Incorrect username or password.');

			}

 			 else if($this->_identity->authenticate() == 3){

            $this->addError('password', 'You can not access this time.');

			}

				 

		}

			}

UserIdentity.php




   if(!isset($user)){ // === NULL

		$this->errorCode = self::ERROR_USERNAME_INVALID;

		

    }

	else if(!$user->validatePassword($this->password)){ // !== Password

         $this->errorCode = self::ERROR_PASSWORD_INVALID;

		

    }

	

	 else if($time_now >= '12:00:00'){ 

	  $this->errorCode=self::ERROR_TIME_INVALID;

            return $this->errorCode;

		

    }   

	else{ 

        $this->username = $user->NAME;

What do you mean by access time? What is the incorrect behaviour of which you want to display an error message?

if try to login after 12.00 then display error message "You can not access this time"

I can solve it’work!!


public function authenticate($attribute,$params)

	{

		if(!$this->hasErrors())

		{

			$this->_identity=new UserIdentity($this->username,$this->password);

			if(!$this->_identity->authenticate()){

				 if($this->_identity->errorCode === UserIdentity::ERROR_TIME_INVALID)

                $this->addError('password','You can not access this time.');

            else

                $this->addError('password','Incorrect email or password.');

				 

		}

			}

				}