Refactors user controller to reduce code complexity for login