Refactor authentication flow
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
@@ -30,32 +30,16 @@ export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthS
|
||||
};
|
||||
oauthService.setupAutomaticSilentRefresh();
|
||||
let location = injector.get(Location);
|
||||
var urlPath =location.path();
|
||||
let router = injector.get(Router);
|
||||
let urlPath = location.path();
|
||||
oauthService.loadDiscoveryDocument().then(() => {
|
||||
oauthService.tryLogin({
|
||||
onTokenReceived: (info) => {
|
||||
urlPath = info.state;
|
||||
}
|
||||
}).then(() => {
|
||||
let router = injector.get(Router);
|
||||
if (!oauthService.hasValidAccessToken()) {
|
||||
if(appConfig.getConfig("grantType") == "code")
|
||||
if(oauthService.getRefreshToken() != null ) {
|
||||
oauthService.refreshToken().then(() => {
|
||||
router.navigateByUrl(urlPath);
|
||||
}).catch(() => {
|
||||
oauthService.initCodeFlow(urlPath);
|
||||
}
|
||||
)
|
||||
} else {
|
||||
oauthService.initCodeFlow(urlPath);
|
||||
}
|
||||
else
|
||||
oauthService.initImplicitFlow(urlPath);
|
||||
} else {
|
||||
router.navigateByUrl(urlPath);
|
||||
}
|
||||
});
|
||||
router.navigateByUrl(urlPath);
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user