From 68f5575a38fc000cc458385a7750dc5616945d10 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Sun, 16 Jul 2017 17:47:02 +0200 Subject: [PATCH] Refactorings. --- .../features/dashboard/pages/dashboard-page.component.ts | 6 +++--- .../app/shared/guards/must-be-authenticated.guard.ts | 4 ++-- .../app/shared/guards/must-be-not-authenticated.guard.ts | 4 ++-- src/Squidex/app/shared/services/apps-store.service.ts | 8 ++++---- src/Squidex/app/shell/pages/home/home-page.component.ts | 6 +++--- .../app/shell/pages/internal/profile-menu.component.ts | 8 ++++---- src/Squidex/app/shell/pages/login/login-page.component.ts | 4 ++-- .../app/shell/pages/logout/logout-page.component.ts | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts index 1e5842ac8..4d72915ad 100644 --- a/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts +++ b/src/Squidex/app/features/dashboard/pages/dashboard-page.component.ts @@ -65,7 +65,7 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit, public callsMax: string | null = null; constructor(apps: AppsStoreService, notifications: NotificationService, - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly usagesService: UsagesService ) { super(notifications, apps); @@ -155,8 +155,8 @@ export class DashboardPageComponent extends AppComponentBase implements OnInit, }); this.authenticationSubscription = - this.auth.isAuthenticated.subscribe(() => { - const user = this.auth.user; + this.authService.isAuthenticated.subscribe(() => { + const user = this.authService.user; if (user) { this.profileDisplayName = user.displayName; diff --git a/src/Squidex/app/shared/guards/must-be-authenticated.guard.ts b/src/Squidex/app/shared/guards/must-be-authenticated.guard.ts index 371bd7947..6a4238df6 100644 --- a/src/Squidex/app/shared/guards/must-be-authenticated.guard.ts +++ b/src/Squidex/app/shared/guards/must-be-authenticated.guard.ts @@ -13,13 +13,13 @@ import { AuthService } from './../services/auth.service'; @Injectable() export class MustBeAuthenticatedGuard implements CanActivate { constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly router: Router ) { } public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { - return this.auth.checkLogin().then(isAuthenticated => { + return this.authService.checkLogin().then(isAuthenticated => { if (!isAuthenticated) { this.router.navigate(['']); } diff --git a/src/Squidex/app/shared/guards/must-be-not-authenticated.guard.ts b/src/Squidex/app/shared/guards/must-be-not-authenticated.guard.ts index cb378b135..c4f92aa3f 100644 --- a/src/Squidex/app/shared/guards/must-be-not-authenticated.guard.ts +++ b/src/Squidex/app/shared/guards/must-be-not-authenticated.guard.ts @@ -13,13 +13,13 @@ import { AuthService } from './../services/auth.service'; @Injectable() export class MustBeNotAuthenticatedGuard implements CanActivate { constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly router: Router ) { } public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { - return this.auth.checkLogin().then(isAuthenticated => { + return this.authService.checkLogin().then(isAuthenticated => { if (isAuthenticated) { this.router.navigate(['app']); } diff --git a/src/Squidex/app/shared/services/apps-store.service.ts b/src/Squidex/app/shared/services/apps-store.service.ts index 7fca62d99..56bb8b680 100644 --- a/src/Squidex/app/shared/services/apps-store.service.ts +++ b/src/Squidex/app/shared/services/apps-store.service.ts @@ -44,10 +44,10 @@ export class AppsStoreService { } constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly appsService: AppsService ) { - if (!auth || !appsService) { + if (!authService || !appsService) { return; } @@ -58,7 +58,7 @@ export class AppsStoreService { this.lastApps = apps; }); - this.auth.isAuthenticated.subscribe(isAuthenticated => { + this.authService.isAuthenticated.subscribe(isAuthenticated => { this.isAuthenticated = isAuthenticated; if (isAuthenticated) { @@ -83,7 +83,7 @@ export class AppsStoreService { public selectApp(name: string | null): Promise { this.appName$.next(name); - return this.selectedApp.take(1).map(app => app !== null).toPromise(); + return this.selectedApp.skip(1).map(app => app !== null).toPromise(); } public createApp(dto: CreateAppDto, now?: DateTime): Observable { diff --git a/src/Squidex/app/shell/pages/home/home-page.component.ts b/src/Squidex/app/shell/pages/home/home-page.component.ts index 27dba9991..3c61e4837 100644 --- a/src/Squidex/app/shell/pages/home/home-page.component.ts +++ b/src/Squidex/app/shell/pages/home/home-page.component.ts @@ -19,16 +19,16 @@ export class HomePageComponent { public showLoginError = false; constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly router: Router ) { } public login() { if (this.isIE()) { - this.auth.loginRedirect(); + this.authService.loginRedirect(); } else { - this.auth.loginPopup() + this.authService.loginPopup() .subscribe(() => { this.router.navigate(['/app']); }, ex => { diff --git a/src/Squidex/app/shell/pages/internal/profile-menu.component.ts b/src/Squidex/app/shell/pages/internal/profile-menu.component.ts index accdf7663..e9b0baae1 100644 --- a/src/Squidex/app/shell/pages/internal/profile-menu.component.ts +++ b/src/Squidex/app/shell/pages/internal/profile-menu.component.ts @@ -36,7 +36,7 @@ export class ProfileMenuComponent implements OnInit, OnDestroy { public profileUrl = this.apiUrl.buildUrl('/identity-server/account/profile'); constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly apiUrl: ApiUrlConfig ) { } @@ -47,9 +47,9 @@ export class ProfileMenuComponent implements OnInit, OnDestroy { public ngOnInit() { this.authenticationSubscription = - this.auth.isAuthenticated.take(1) + this.authService.isAuthenticated.take(1) .subscribe(() => { - const user = this.auth.user; + const user = this.authService.user; if (user) { this.profileId = user.id; @@ -61,6 +61,6 @@ export class ProfileMenuComponent implements OnInit, OnDestroy { } public logout() { - this.auth.logoutRedirect(); + this.authService.logoutRedirect(); } } \ No newline at end of file diff --git a/src/Squidex/app/shell/pages/login/login-page.component.ts b/src/Squidex/app/shell/pages/login/login-page.component.ts index d4baf4e29..bd6340043 100644 --- a/src/Squidex/app/shell/pages/login/login-page.component.ts +++ b/src/Squidex/app/shell/pages/login/login-page.component.ts @@ -16,13 +16,13 @@ import { AuthService } from 'shared'; }) export class LoginPageComponent implements OnInit { constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly router: Router ) { } public ngOnInit() { - this.auth.loginRedirectComplete() + this.authService.loginRedirectComplete() .subscribe( () => { this.router.navigate(['/app'], { replaceUrl: true }); diff --git a/src/Squidex/app/shell/pages/logout/logout-page.component.ts b/src/Squidex/app/shell/pages/logout/logout-page.component.ts index e17c1d1e1..416b95a56 100644 --- a/src/Squidex/app/shell/pages/logout/logout-page.component.ts +++ b/src/Squidex/app/shell/pages/logout/logout-page.component.ts @@ -16,13 +16,13 @@ import { AuthService } from 'shared'; }) export class LogoutPageComponent implements OnInit { constructor( - private readonly auth: AuthService, + private readonly authService: AuthService, private readonly router: Router ) { } public ngOnInit() { - this.auth.logoutRedirectComplete() + this.authService.logoutRedirectComplete() .subscribe( () => { this.router.navigate(['/'], { replaceUrl: true });