From 6cb48028ea2c5de58faf0160efd2dc010a4fae39 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Mon, 17 Jul 2017 18:02:33 +0200 Subject: [PATCH] Login problems fixed (I hope): #71 --- .../app/shared/services/apps-store.service.ts | 2 +- src/Squidex/app/shared/services/auth.service.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Squidex/app/shared/services/apps-store.service.ts b/src/Squidex/app/shared/services/apps-store.service.ts index 934ef21df..d5c5f84a9 100644 --- a/src/Squidex/app/shared/services/apps-store.service.ts +++ b/src/Squidex/app/shared/services/apps-store.service.ts @@ -18,7 +18,7 @@ import { @Injectable() export class AppsStoreService { - private readonly apps$ = new ReplaySubject(); + private readonly apps$ = new ReplaySubject(1); private readonly app$ = new BehaviorSubject(null); public get apps(): Observable { diff --git a/src/Squidex/app/shared/services/auth.service.ts b/src/Squidex/app/shared/services/auth.service.ts index c22933116..4caef7624 100644 --- a/src/Squidex/app/shared/services/auth.service.ts +++ b/src/Squidex/app/shared/services/auth.service.ts @@ -54,7 +54,7 @@ export class Profile { @Injectable() export class AuthService { private readonly userManager: UserManager; - private readonly user$ = new ReplaySubject(); + private readonly user$ = new ReplaySubject(1); private currentUser: Profile = null; public get user(): Profile | null { @@ -96,7 +96,7 @@ export class AuthService { this.currentUser = user; }); - this.userManager.signinSilent(); + this.checkState(this.userManager.signinSilent()); } public logoutRedirect(): Observable { @@ -118,4 +118,12 @@ export class AuthService { public loginRedirectComplete(): Observable { return Observable.fromPromise(this.userManager.signinRedirectCallback()); } + + private checkState(promise: Promise) { + promise.catch((err) => { + this.user$.next(null); + + return false; + }); + } } \ No newline at end of file