import { Injectable } from '@angular/core'; import { HttpHeaders } from '@angular/common/http'; import { AbstractAgent, IPostOptions } from '@creedinteractive/onguard-models'; import { VerbsService, BusService } from '@creedinteractive/onguard-ng-services'; import { LaunchpadEventsService } from '../launchpad-events/launchpad-events.service'; @Injectable({ providedIn: 'root', }) export class LogLogoutService extends AbstractAgent { constructor( private bus: BusService, private eventsService: LaunchpadEventsService, private verbs: VerbsService, ) { super(); this.options = { uri: '/auth/logLogout', body: '', handlers: { success: this.success.bind(this), error: this.error.bind(this), }, headers: new HttpHeaders().set('Content-Type', 'application/json'), }; this.subscribe(); } public success(): void {} public error(): void {} public request(): void { this.verbs.post(this.options as IPostOptions); setTimeout(() => { this.bus.publish(this.eventsService.user.logout); }, 200); } public subscribe(): void { this.bus.subscribe(this.eventsService.user.logLogout, this.request.bind(this)); } }