Check for existing users RealmSwift

Hello! I am struggling a bit with my authentication flow. I have been able to get Google Auth, Apple Auth and Email/password auth working but now I have ran into the following problem:

When I try to create a new account with an email that already has an existing account on my app it still redirects it to the create account view while it should just log the user in. Same thing for when a user logs in without an active account on my app it should be redirected to the create account view instead of being logged in.

I was thinking about checking whether the email address is already present in the database and use that in a simple if else statement to decide if the create account view should be shown or not. But since this is happening before a user is signed in I don’t have ‘access’ to the realm. So what would be the best way to check if a user already has an account or not?

Thanks in advance!