Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let logout.component use form configs #78

Merged
merged 9 commits into from
Dec 19, 2017
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);
}
}