From 4eb9a393e80f68d38be8a8dc0b5b1dd46514e275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinan=20=C3=96zt=C3=BCrk?= Date: Fri, 9 Feb 2024 16:56:16 +0300 Subject: [PATCH] Fix bug while setting value to RememberMeService and enhancement for IAuthService interface --- .../packages/core/src/lib/abstracts/auth.service.ts | 11 +++++++++++ .../packages/oauth/src/lib/services/oauth.service.ts | 8 ++++++++ .../packages/oauth/src/lib/utils/auth-utils.ts | 8 +++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/core/src/lib/abstracts/auth.service.ts b/npm/ng-packs/packages/core/src/lib/abstracts/auth.service.ts index fd28a88e68c..e797b9d25f7 100644 --- a/npm/ng-packs/packages/core/src/lib/abstracts/auth.service.ts +++ b/npm/ng-packs/packages/core/src/lib/abstracts/auth.service.ts @@ -16,6 +16,15 @@ export class AuthService implements IAuthService { console.error('You should add @abp/ng-oauth packages or create your own auth packages.'); } + get oidc(): boolean { + this.warningMessage(); + return false; + } + + set oidc(value: boolean) { + this.warningMessage(); + } + init(): Promise { this.warningMessage(); return Promise.resolve(undefined); @@ -73,6 +82,8 @@ export class AuthService implements IAuthService { } export interface IAuthService { + oidc: boolean; + get isInternalAuth(): boolean; get isAuthenticated(): boolean; diff --git a/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts b/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts index aea8fa11671..a490f92dd2f 100644 --- a/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts +++ b/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts @@ -16,6 +16,14 @@ export class AbpOAuthService implements IAuthService { private strategy!: AuthFlowStrategy; private readonly oAuthService: OAuthService; + get oidc() { + return this.oAuthService.oidc; + } + + set oidc(value) { + this.oAuthService.oidc = value; + } + get isInternalAuth() { return this.strategy.isInternalAuth; } diff --git a/npm/ng-packs/packages/oauth/src/lib/utils/auth-utils.ts b/npm/ng-packs/packages/oauth/src/lib/utils/auth-utils.ts index bc76609f5a6..7bff53a4860 100644 --- a/npm/ng-packs/packages/oauth/src/lib/utils/auth-utils.ts +++ b/npm/ng-packs/packages/oauth/src/lib/utils/auth-utils.ts @@ -3,6 +3,7 @@ import { Router } from '@angular/router'; import { pipe } from 'rxjs'; import { switchMap, tap } from 'rxjs/operators'; import { + AuthService, ConfigStateService, LoginParams, PipeToLoginFn, @@ -16,10 +17,15 @@ export const pipeToLogin: PipeToLoginFn = function ( const configState = injector.get(ConfigStateService); const router = injector.get(Router); const rememberMeService = injector.get(RememberMeService); + const authService = injector.get(AuthService); return pipe( switchMap(() => configState.refreshAppState()), tap(() => { - rememberMeService.set(params.rememberMe); + rememberMeService.set( + params.rememberMe || + rememberMeService.get() || + rememberMeService.getFromToken(authService.getAccessToken()) + ); if (params.redirectUrl) router.navigate([params.redirectUrl]); }), );