Login controller and refactorings