Moving some logic out of the LoginController to enable users to write th...

...eir own custom controller