Complete login function for the application.