Refactor authentication flow
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
62887e8089
commit
baf8767a91
@ -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',
|
||||
|
@ -1,12 +1,19 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'fm-auth-callback',
|
||||
template:'<div></div>'
|
||||
})
|
||||
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:'<div></div>'
|
||||
})
|
||||
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):"");
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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 [];
|
||||
}));
|
||||
|
||||
|
@ -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());
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ const routes = [
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes,
|
||||
{ initialNavigation: false })], // , enableTracing: true
|
||||
{ initialNavigation: true })], // , enableTracing: true
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
|
Loading…
Reference in New Issue
Block a user