diff --git a/projects/common/src/fm/common-routing.module.ts b/projects/common/src/fm/common-routing.module.ts index 3bc5ab8..d02f375 100644 --- a/projects/common/src/fm/common-routing.module.ts +++ b/projects/common/src/fm/common-routing.module.ts @@ -12,8 +12,7 @@ import {NotFoundComponent} from './components/not-found/not-found.component'; const routes = [ { path: 'cb', - component: AuthCallbackComponent, - canActivate: [AuthCallbackGuard], + component: AuthCallbackComponent }, { path: 'loggedout', diff --git a/projects/common/src/fm/components/auth-callback/auth-callback.component.ts b/projects/common/src/fm/components/auth-callback/auth-callback.component.ts index 9c4bb53..74ccef2 100644 --- a/projects/common/src/fm/components/auth-callback/auth-callback.component.ts +++ b/projects/common/src/fm/components/auth-callback/auth-callback.component.ts @@ -1,12 +1,19 @@ -import { Component } from '@angular/core'; - - -@Component({ - selector: 'fm-auth-callback', - template:'
' -}) -export class AuthCallbackComponent { - - constructor() { - } -} +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; +import { OAuthService } from 'angular-oauth2-oidc'; +import { Location} from '@angular/common'; + +@Component({ + selector: 'fm-auth-callback', + template:'
' +}) +export class AuthCallbackComponent { + + constructor(private router$: Router,private oauthService$:OAuthService) { + oauthService$.loadDiscoveryDocument().then(() => { + oauthService$.tryLoginCodeFlow().then(() => { + router$.navigateByUrl((oauthService$.state && oauthService$.state!="")?decodeURIComponent(oauthService$.state):""); + }); + }) + } +} diff --git a/projects/common/src/fm/effects/app-common.effects.ts b/projects/common/src/fm/effects/app-common.effects.ts index 315b116..74d87c6 100644 --- a/projects/common/src/fm/effects/app-common.effects.ts +++ b/projects/common/src/fm/effects/app-common.effects.ts @@ -25,7 +25,7 @@ export class AppCommonEffects { withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)), mergeMap(([action, initialized]) => { var a = (action as appCommonActions.Login); - this.oauthService$.initImplicitFlow(a.url); + this.oauthService$.initCodeFlow(a.url); return []; })); diff --git a/projects/common/src/fm/shared/app.config.factory.ts b/projects/common/src/fm/shared/app.config.factory.ts index b7a8a2f..f804b4e 100644 --- a/projects/common/src/fm/shared/app.config.factory.ts +++ b/projects/common/src/fm/shared/app.config.factory.ts @@ -27,17 +27,10 @@ export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthS oauthService.configure(authconfigFactory.getAuthConfig(appConfig)); oauthService.setStorage(authStorage); oauthService.setupAutomaticSilentRefresh(); - let location = injector.get(Location); - let router = injector.get(Router); - let urlPath = location.path(); - oauthService.loadDiscoveryDocument().then(() => { - oauthService.tryLoginCodeFlow().then(() => { - router.navigateByUrl((oauthService.state && oauthService.state!="")?decodeURIComponent(oauthService.state):urlPath); - }); - }) - }).then(() => { + }).then(() => oauthService.loadDiscoveryDocument() + ).then(() => { itemtypeService.load(appConfig).then(() => resolve()).catch(() => reject()); - }); + }) }); } } diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 78019f3..601f3d2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -62,7 +62,7 @@ const routes = [ @NgModule({ imports: [RouterModule.forRoot(routes, - { initialNavigation: false })], // , enableTracing: true + { initialNavigation: true })], // , enableTracing: true exports: [RouterModule] }) export class AppRoutingModule { }