Browse Source

code flow authentication update

feature/ssr-migration-schematic
erdemcaygor 1 year ago
parent
commit
eb160b67d1
  1. 15
      npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts

15
npm/ng-packs/packages/oauth/src/lib/strategies/auth-code-flow-strategy.ts

@ -1,4 +1,4 @@
import { Inject, PLATFORM_ID } from '@angular/core'; import { Injector, PLATFORM_ID } from '@angular/core';
import { noop } from '@abp/ng.core'; import { noop } from '@abp/ng.core';
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import { filter, from, of, take, tap } from 'rxjs'; import { filter, from, of, take, tap } from 'rxjs';
@ -8,7 +8,12 @@ import { isPlatformBrowser } from '@angular/common';
export class AuthCodeFlowStrategy extends AuthFlowStrategy { export class AuthCodeFlowStrategy extends AuthFlowStrategy {
readonly isInternalAuth = false; readonly isInternalAuth = false;
@Inject(PLATFORM_ID) platformId: string; private platformId: object;
constructor(protected injector: Injector) {
super(injector);
this.platformId = injector.get(PLATFORM_ID);
}
async init() { async init() {
this.checkRememberMeOption(); this.checkRememberMeOption();
@ -69,6 +74,7 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
} }
protected listenToTokenReceived() { protected listenToTokenReceived() {
console.log('listenToTokenReceived');
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
this.oAuthService.events this.oAuthService.events
.pipe( .pipe(
@ -84,6 +90,8 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
} }
navigateToLogin(queryParams?: Params) { navigateToLogin(queryParams?: Params) {
console.log('navigateToLogin');
console.log(isPlatformBrowser(this.platformId));
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
let additionalState = ''; let additionalState = '';
if (queryParams?.returnUrl) { if (queryParams?.returnUrl) {
@ -96,6 +104,7 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
} }
checkIfInternalAuth(queryParams?: Params) { checkIfInternalAuth(queryParams?: Params) {
console.log('checkIfInternalAuth');
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams)); this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams));
return false; return false;
@ -112,6 +121,8 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
} }
login(queryParams?: Params) { login(queryParams?: Params) {
console.log('login');
console.log(isPlatformBrowser(this.platformId));
if (isPlatformBrowser(this.platformId)) { if (isPlatformBrowser(this.platformId)) {
this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams)); this.oAuthService.initCodeFlow('', this.getCultureParams(queryParams));
return of(null); return of(null);

Loading…
Cancel
Save