Skip to content

Commit

Permalink
Merge pull request #8171 from abpframework/feat/volo-5594
Browse files Browse the repository at this point in the history
Angular UI: Added queryParam as a optional method parameter to the navigateToLogin method of AuthService
  • Loading branch information
bnymncoskuner committed Mar 23, 2021
2 parents 8586585 + fac5707 commit 73ceffc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions npm/ng-packs/packages/core/src/lib/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 73ceffc

Please sign in to comment.