Move login functionality into the app controller