Resolver to authenticate user via passwordless or custom-database?

So we have this requirement were we should allow users to log into our app via either a database connection or passwordless.

The goal is that if the user exists in the database connection, we authenticate them using that connection, but if they don’t exist, we want them to authenticate via a passwordless connection.

I’ve read about resolvers but they only apply to database connections.

Is there a way to initiate the authentication flow, request the users email, and then run some code to determine if the user should be authenticated via the custom database flow or the passwordless flow? Can actions be used to achieve this?