Moving some logic out of the LoginController to enable users to write their own custom controller