Added code to handle login and post login actions