Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug while setting value to RememberMeService and enhancement for IAuthService interface #18983

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions npm/ng-packs/packages/core/src/lib/abstracts/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
this.warningMessage();
return Promise.resolve(undefined);
Expand Down Expand Up @@ -73,6 +82,8 @@ export class AuthService implements IAuthService {
}

export interface IAuthService {
oidc: boolean;

get isInternalAuth(): boolean;

get isAuthenticated(): boolean;
Expand Down
8 changes: 8 additions & 0 deletions npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion npm/ng-packs/packages/oauth/src/lib/utils/auth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Router } from '@angular/router';
import { pipe } from 'rxjs';
import { switchMap, tap } from 'rxjs/operators';
import {
AuthService,
ConfigStateService,
LoginParams,
PipeToLoginFn,
Expand All @@ -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]);
}),
);
Expand Down