Added error handling to login, set up redirect