UNPKG

@nebular/auth

Version:
49 lines 1.71 kB
/** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ import { Component, Inject } from '@angular/core'; import { Router } from '@angular/router'; import { NB_AUTH_OPTIONS } from '../../auth.options'; import { getDeepFromObject } from '../../helpers'; import { NbAuthService } from '../../services/auth.service'; export class NbLogoutComponent { constructor(service, options = {}, router) { this.service = service; this.options = options; this.router = router; this.redirectDelay = 0; this.strategy = ''; this.redirectDelay = this.getConfigValue('forms.logout.redirectDelay'); this.strategy = this.getConfigValue('forms.logout.strategy'); } ngOnInit() { this.logout(this.strategy); } logout(strategy) { this.service.logout(strategy).subscribe((result) => { const redirect = result.getRedirect(); if (redirect) { setTimeout(() => { return this.router.navigateByUrl(redirect); }, this.redirectDelay); } }); } getConfigValue(key) { return getDeepFromObject(this.options, key, null); } } NbLogoutComponent.decorators = [ { type: Component, args: [{ selector: 'nb-logout', template: "<div>Logging out, please wait...</div>\n" },] } ]; NbLogoutComponent.ctorParameters = () => [ { type: NbAuthService }, { type: undefined, decorators: [{ type: Inject, args: [NB_AUTH_OPTIONS,] }] }, { type: Router } ]; //# sourceMappingURL=logout.component.js.map