angular script and api call only happens now if user is logged in