Loading libs/authentication/src/lib/authentication.service.ts +17 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,8 @@ import { } from '@angular/core'; import { BehaviorSubject, Observable Observable, Subject } from 'rxjs'; import { Router } from '@angular/router'; import { tap } from 'rxjs/operators'; Loading Loading @@ -46,12 +47,24 @@ export function TimeoutResolve<T>(value: T, ms: number): Promise<T> { }); } export enum AuthenticationEventType { OnAuthSuccess = 'on-auth-success', OnAuthError = 'on-auth-error', OnLogout = 'on-logout', } export interface AuthenticationEvent extends Record<string, any> { type: AuthenticationEventType; } @Injectable({ providedIn: 'root' }) /* ignore coverage */ export class RxapAuthenticationService implements IAuthenticationService { public isAuthenticated$ = new BehaviorSubject<boolean | null>(null); public readonly events$ = new Subject<AuthenticationEvent>(); constructor() { console.warn('The default RxapAuthenticationService implementation should only be used in a development environment!'); this.isAuthenticated().then(isAuthenticated => this.isAuthenticated$.next(isAuthenticated)); Loading @@ -78,9 +91,11 @@ export class RxapAuthenticationService implements IAuthenticationService { localStorage.setItem(RXAP_AUTHENTICATION_LOCAL_STORAGE_KEY, 'true'); } resolve(login); this.events$.next({ type: AuthenticationEventType.OnAuthSuccess }); } else { localStorage.removeItem(RXAP_AUTHENTICATION_LOCAL_STORAGE_KEY); reject(new Error('Login credentials are invalid')); this.events$.next({ type: AuthenticationEventType.OnAuthError }); } }, 2500); Loading @@ -91,6 +106,7 @@ export class RxapAuthenticationService implements IAuthenticationService { console.warn('The default RxapAuthenticationService implementation should only be used in a development environment!'); this.isAuthenticated$.next(false); localStorage.removeItem(RXAP_AUTHENTICATION_LOCAL_STORAGE_KEY); this.events$.next({ type: AuthenticationEventType.OnLogout }); } public signInWithProvider(provider: string): Promise<boolean> { Loading Loading
libs/authentication/src/lib/authentication.service.ts +17 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,8 @@ import { } from '@angular/core'; import { BehaviorSubject, Observable Observable, Subject } from 'rxjs'; import { Router } from '@angular/router'; import { tap } from 'rxjs/operators'; Loading Loading @@ -46,12 +47,24 @@ export function TimeoutResolve<T>(value: T, ms: number): Promise<T> { }); } export enum AuthenticationEventType { OnAuthSuccess = 'on-auth-success', OnAuthError = 'on-auth-error', OnLogout = 'on-logout', } export interface AuthenticationEvent extends Record<string, any> { type: AuthenticationEventType; } @Injectable({ providedIn: 'root' }) /* ignore coverage */ export class RxapAuthenticationService implements IAuthenticationService { public isAuthenticated$ = new BehaviorSubject<boolean | null>(null); public readonly events$ = new Subject<AuthenticationEvent>(); constructor() { console.warn('The default RxapAuthenticationService implementation should only be used in a development environment!'); this.isAuthenticated().then(isAuthenticated => this.isAuthenticated$.next(isAuthenticated)); Loading @@ -78,9 +91,11 @@ export class RxapAuthenticationService implements IAuthenticationService { localStorage.setItem(RXAP_AUTHENTICATION_LOCAL_STORAGE_KEY, 'true'); } resolve(login); this.events$.next({ type: AuthenticationEventType.OnAuthSuccess }); } else { localStorage.removeItem(RXAP_AUTHENTICATION_LOCAL_STORAGE_KEY); reject(new Error('Login credentials are invalid')); this.events$.next({ type: AuthenticationEventType.OnAuthError }); } }, 2500); Loading @@ -91,6 +106,7 @@ export class RxapAuthenticationService implements IAuthenticationService { console.warn('The default RxapAuthenticationService implementation should only be used in a development environment!'); this.isAuthenticated$.next(false); localStorage.removeItem(RXAP_AUTHENTICATION_LOCAL_STORAGE_KEY); this.events$.next({ type: AuthenticationEventType.OnLogout }); } public signInWithProvider(provider: string): Promise<boolean> { Loading