From d641f83f9b02dea4ef8946310d3913ae64465a17 Mon Sep 17 00:00:00 2001 From: Alexander Wellbrock Date: Thu, 16 Nov 2017 22:02:41 +0100 Subject: [PATCH 1/5] Let logout.component use form configs --- .../auth/components/logout/logout.component.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/framework/auth/components/logout/logout.component.ts b/src/framework/auth/components/logout/logout.component.ts index e88f18a17b..ef54ea4c77 100644 --- a/src/framework/auth/components/logout/logout.component.ts +++ b/src/framework/auth/components/logout/logout.component.ts @@ -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 '@nebular/auth/auth.options'; +import { getDeepFromObject } from '@nebular/auth/helpers'; import { NbAuthService, NbAuthResult } from '../../services/auth.service'; @Component({ @@ -19,11 +21,12 @@ export class NbLogoutComponent implements OnInit { redirectDelay: number = 1500; constructor(protected service: NbAuthService, + @Inject(NB_AUTH_OPTIONS_TOKEN) protected config = {}, protected router: Router) { } ngOnInit(): void { - this.logout('email'); + this.logout(this.getConfigValue('forms.logout.provider')); } logout(provider: string): void { @@ -37,4 +40,9 @@ export class NbLogoutComponent implements OnInit { } }); } + + + getConfigValue(key: string): any { + return getDeepFromObject(this.config, key, null); + } } From 250b8cd166d81c25d476c78f6a1aff9c930cb804 Mon Sep 17 00:00:00 2001 From: Alexander Wellbrock Date: Thu, 16 Nov 2017 22:55:35 +0100 Subject: [PATCH 2/5] Correct paths to auth.options and helpers --- src/framework/auth/components/logout/logout.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/framework/auth/components/logout/logout.component.ts b/src/framework/auth/components/logout/logout.component.ts index ef54ea4c77..eb0ff0f47f 100644 --- a/src/framework/auth/components/logout/logout.component.ts +++ b/src/framework/auth/components/logout/logout.component.ts @@ -6,8 +6,8 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Router } from '@angular/router'; -import { NB_AUTH_OPTIONS_TOKEN } from '@nebular/auth/auth.options'; -import { getDeepFromObject } from '@nebular/auth/helpers'; +import { NB_AUTH_OPTIONS_TOKEN } from '../../auth.options'; +import { getDeepFromObject } from '../../helpers'; import { NbAuthService, NbAuthResult } from '../../services/auth.service'; @Component({ From 1a9184a1952f443254dab6557b04a69f5cc1518c Mon Sep 17 00:00:00 2001 From: Dmitry Nehaychik <4dmitr@gmail.com> Date: Tue, 19 Dec 2017 13:27:17 +0300 Subject: [PATCH 3/5] refactor(logout): remove unnecessary empty line --- src/framework/auth/components/logout/logout.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/framework/auth/components/logout/logout.component.ts b/src/framework/auth/components/logout/logout.component.ts index eb0ff0f47f..98ff91ee71 100644 --- a/src/framework/auth/components/logout/logout.component.ts +++ b/src/framework/auth/components/logout/logout.component.ts @@ -41,7 +41,6 @@ export class NbLogoutComponent implements OnInit { }); } - getConfigValue(key: string): any { return getDeepFromObject(this.config, key, null); } From 20bf0cb9aa3a91409b8dedfb83b91499e0a262c1 Mon Sep 17 00:00:00 2001 From: Dmitry Nehaychik <4dmitr@gmail.com> Date: Tue, 19 Dec 2017 13:30:06 +0300 Subject: [PATCH 4/5] fix(logout): make use of redirectDelay --- src/framework/auth/components/logout/logout.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/framework/auth/components/logout/logout.component.ts b/src/framework/auth/components/logout/logout.component.ts index 98ff91ee71..fb8308b43f 100644 --- a/src/framework/auth/components/logout/logout.component.ts +++ b/src/framework/auth/components/logout/logout.component.ts @@ -18,15 +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(this.getConfigValue('forms.logout.provider')); + this.logout(this.provider); } logout(provider: string): void { From c24fc403c2ec8d9a871d34fef9a4d8c52d73614d Mon Sep 17 00:00:00 2001 From: Dmitry Nehaychik <4dmitr@gmail.com> Date: Tue, 19 Dec 2017 13:34:50 +0300 Subject: [PATCH 5/5] refactor(logout): remove space --- src/framework/auth/components/logout/logout.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/framework/auth/components/logout/logout.component.ts b/src/framework/auth/components/logout/logout.component.ts index fb8308b43f..759e36f057 100644 --- a/src/framework/auth/components/logout/logout.component.ts +++ b/src/framework/auth/components/logout/logout.component.ts @@ -43,7 +43,7 @@ export class NbLogoutComponent implements OnInit { } }); } - + getConfigValue(key: string): any { return getDeepFromObject(this.config, key, null); }