implements routing and checks if user is logged in.