In general it's bad practice to change the default database connection under a certain condition. Also the user needs to be loaded on any (logged in) request, not just in the login request.
But there is of course a symfony way to achieve to load the user froma different database.
You would need to implement your own UserProvider that loads the user from a different database connection. Here is an example of a userprovider.