BeforeLogin Event Custom Error

hi guys i am new to yii frameworks

i need return a custom error saying Account Blocked when beforelogin event is triggered

I have written User class that extends yii\web\User… i am overriding beforelogin method…

In this event i want check weather the user is blocked or not…

So i want to know how get User id from database and if user is blocked then i need to send custom error back to login form… but since beforelogin method return boolean how to implement this… please help me… Thanks in Advance

protected function beforeLogin($identity, $cookieBased, $duration) 


        parent::beforeLogin($identity, $cookieBased, $duration);

       [b] if user is blocked then send custom error back to loginform[/b]

        return true;