Version 4 Authentication

You were doing this in your login function? Just do it in a bit of middleware instead, which you load before the authentication middleware? Or write a custom authenticator?