More migration fixes

This commit is contained in:
Willem Dantuma
2020-04-01 16:11:44 +02:00
parent 511f1f4731
commit 80ddf816b0
10 changed files with 43 additions and 59 deletions

View File

@@ -38,24 +38,19 @@ export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
checkLogin(url: string): boolean {
if (!this.oauthService.hasValidAccessToken()) {
this.oauthService.responseType
if(this.oauthService.responseType == "code")
if(this.oauthService.getRefreshToken() != null ) {
this.oauthService.refreshToken().then(() => {
this.store.dispatch(new appCommonActions.InitUser());
return true;
}).catch(() => {
this.oauthService.initCodeFlow(url);
return false;
}
)
} else {
if(this.oauthService.getRefreshToken() != null ) {
this.oauthService.refreshToken().then(() => {
this.store.dispatch(new appCommonActions.InitUser());
return true;
}).catch(() => {
this.oauthService.initCodeFlow(url);
return false;
}
else
this.oauthService.initImplicitFlow(url);
}
)
} else {
this.oauthService.initCodeFlow(url);
return false;
}
} else {
this.store.dispatch(new appCommonActions.InitUser());
return true;

View File

@@ -1,7 +1,7 @@
import { Injector } from '@angular/core';
import { Location} from '@angular/common';
import { Router,UrlSerializer } from '@angular/router';
import { AuthConfig, OAuthService, JwksValidationHandler, OAuthErrorEvent, OAuthStorage } from 'angular-oauth2-oidc';
import { AuthConfig, OAuthService, OAuthErrorEvent, OAuthStorage } from 'angular-oauth2-oidc';
import { AppConfig } from "./app.config";
import {ItemTypeService} from '../services/itemtype.service';
import { IAuthconfigFactory } from './authconfigFactory';
@@ -26,21 +26,12 @@ export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthS
});
oauthService.configure(authconfigFactory.getAuthConfig(appConfig));
oauthService.setStorage(authStorage);
oauthService.tokenValidationHandler = new JwksValidationHandler();
oauthService.tokenValidationHandler.validateAtHash = function () {
return new Promise<boolean>((res) => { res(true); })
};
oauthService.setupAutomaticSilentRefresh();
let location = injector.get(Location);
let router = injector.get(Router);
let urlPath = location.path();
oauthService.loadDiscoveryDocument().then(() => {
oauthService.tryLogin({
onTokenReceived: (info) => {
urlPath = info.state;
}
}).then(() => {
router.navigateByUrl(urlPath);
oauthService.tryLoginCodeFlow().then(() => {
router.navigateByUrl(decodeURIComponent(oauthService.state));
});
})
}).then(() => {

View File

@@ -29,10 +29,11 @@
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
"enableResourceInlining": true,
"enableIvy": false
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
]
}

View File

@@ -1,6 +0,0 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
}
}