Added login and redirect functionality