Lock user after 5 login attempts

Hi, i am new to use Yii. Can anyone tell me how to lock user after 5 attempts?

Thank you

Which user do you want to lock?

The user that already attempt 5 times but still got the password wrong, if the user want to unlock the account, they need to contact the admin

add field tracking attempts and with each wrong attempt…

That is not particularly good idea. If I know another user login and want to make his life harder I can do this 5 times a day and his account will be locked.

To counter that, you might want to send unlock code on SMS/email and ask for that code
That way time delays are averted