Split the login mechanism into MVC pattern