adding logic to redirect to login page if user is not authenticated