AngularJs service for managing login/logout and basic authentication of API endpoints