login with username or email

Hey guys, I have my profiles table where I save the user username. I would like that in my login screen, the user could login with both, email or username. My profiles table has a everyone can read policy which means that I can get the profile with the username on my login screen.

But the thing is how could I login with this username? Is there some kind of configuration that I could enable? Because I can't get the auth.users with the profile uid, or can I?
Was this page helpful?