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

Angular UI: Added queryParam as a optional method parameter to the navigateToLogin method of AuthService #8171

Merged
merged 2 commits into from
Mar 23, 2021
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
5 changes: 3 additions & 2 deletions npm/ng-packs/packages/core/src/lib/services/auth.service.ts
@@ -1,4 +1,5 @@
import { Injectable, Injector } from '@angular/core';
import { Params } from '@angular/router';
import { from, Observable } from 'rxjs';
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
import {
Expand Down Expand Up @@ -51,8 +52,8 @@ export class AuthService {
this.strategy.navigateToLogin();
}

navigateToLogin() {
this.strategy.navigateToLogin();
navigateToLogin(queryParams?: Params) {
this.strategy.navigateToLogin(queryParams);
}

login(params: LoginParams) {
Expand Down
@@ -1,6 +1,6 @@
import { HttpHeaders } from '@angular/common/http';
import { Injector } from '@angular/core';
import { Router } from '@angular/router';
import { Params, Router } from '@angular/router';
import { Store } from '@ngxs/store';
import { AuthConfig, OAuthInfoEvent, OAuthService, OAuthStorage } from 'angular-oauth2-oidc';
import { from, Observable, of } from 'rxjs';
Expand Down Expand Up @@ -29,7 +29,7 @@ export abstract class AuthFlowStrategy {
protected oAuthService: OAuthService;
protected oAuthConfig: AuthConfig;
abstract checkIfInternalAuth(): boolean;
abstract navigateToLogin(): void;
abstract navigateToLogin(queryParams?: Params): void;
abstract logout(): Observable<any>;
abstract login(params?: LoginParams): Observable<any>;

Expand Down Expand Up @@ -78,8 +78,8 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
.then(() => this.oAuthService.setupAutomaticSilentRefresh({}, 'access_token'));
}

navigateToLogin() {
this.oAuthService.initCodeFlow();
navigateToLogin(queryParams?: Params) {
this.oAuthService.initCodeFlow(null, queryParams);
}

checkIfInternalAuth() {
Expand Down Expand Up @@ -147,9 +147,9 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
return super.init().then(() => this.listenToTokenExpiration());
}

navigateToLogin() {
navigateToLogin(queryParams?: Params) {
const router = this.injector.get(Router);
router.navigateByUrl('/account/login');
router.navigate(['/account/login'], { queryParams });
}

checkIfInternalAuth() {
Expand All @@ -172,7 +172,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
tap(res => {
this.configState.setState(res);
this.setRememberMe(params.rememberMe);
router.navigate([params.redirectUrl || '/']);
if (params.redirectUrl) router.navigate([params.redirectUrl]);
}),
);
}
Expand Down
Expand Up @@ -193,10 +193,10 @@ export class ModalComponent implements OnDestroy {
fromEvent(window, 'beforeunload')
.pipe(takeUntil(this.destroy$))
.subscribe(event => {
if (this.isFormDirty) {
event.preventDefault();
if (this.isFormDirty && !this.suppressUnsavedChangesWarning) {
event.returnValue = true;
} else {
event.returnValue = false;
delete event.returnValue;
}
});
Expand Down