Restricting access with user name instead of mail. Possible?

I have a restricting access on a page.

Everything works perfect. Now the customer wants to login with his username instead of the mail address. Possible?

I guess I have to change this one: if ($user = $kirby->user(get(‘email’))) {

But I could not find out, how I can check the username.

Thanks for any help!

Since only the email needs to be unique, using the username instead of the email address is not such a good idea.

It is a restricted area where like 50 people should have access. Share the same login is more easy and a username makes more sense as a generic mail address.

Thanks! Perfect!