Skip to content

Commit

Permalink
feat(logout): let logout.component use form configs (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Wellbrock authored and nnixaa committed Dec 19, 2017
1 parent 336b05e commit 41d0f78
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/framework/auth/components/logout/logout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { Component, OnInit } from '@angular/core';
import { Component, Inject, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { NB_AUTH_OPTIONS_TOKEN } from '../../auth.options';
import { getDeepFromObject } from '../../helpers';
import { NbAuthService, NbAuthResult } from '../../services/auth.service';

@Component({
Expand All @@ -16,14 +18,18 @@ import { NbAuthService, NbAuthResult } from '../../services/auth.service';
})
export class NbLogoutComponent implements OnInit {

redirectDelay: number = 1500;
redirectDelay: number = 0;
provider: string = '';

constructor(protected service: NbAuthService,
@Inject(NB_AUTH_OPTIONS_TOKEN) protected config = {},
protected router: Router) {
this.redirectDelay = this.getConfigValue('forms.logout.redirectDelay');
this.provider = this.getConfigValue('forms.logout.provider');
}

ngOnInit(): void {
this.logout('email');
this.logout(this.provider);
}

logout(provider: string): void {
Expand All @@ -37,4 +43,8 @@ export class NbLogoutComponent implements OnInit {
}
});
}

getConfigValue(key: string): any {
return getDeepFromObject(this.config, key, null);
}
}

0 comments on commit 41d0f78

Please sign in to comment.