More migration fixes
This commit is contained in:
@@ -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;
|
||||
|
@@ -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(() => {
|
||||
|
@@ -29,10 +29,11 @@
|
||||
"strictMetadataEmit": true,
|
||||
"fullTemplateTypeCheck": true,
|
||||
"strictInjectionParameters": true,
|
||||
"enableResourceInlining": true
|
||||
"enableResourceInlining": true,
|
||||
"enableIvy": false
|
||||
},
|
||||
"exclude": [
|
||||
"src/test.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
]
|
||||
}
|
||||
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.lib.json",
|
||||
"angularCompilerOptions": {
|
||||
"enableIvy": false
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user