Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
canActivate(route, state) {
this.authService.getLogger().verbose("location change event from old url to new url");
this.authService.updateDataFromCache([this.config.clientID]);
if (!this.authService._oauthData.isAuthenticated && !this.authService._oauthData.userName) {
if (state.url) {
if (!this.authService._renewActive && !this.authService.loginInProgress()) {
var loginStartPage = this.getBaseUrl() + state.url;
if (loginStartPage !== null) {
this.authService.getCacheStorage().setItem(Constants.angularLoginRequest, loginStartPage);
}
if (this.config.popUp) {
return new Promise((resolve, reject) => {
this.authService.loginPopup(this.config.consentScopes, this.config.extraQueryParameters).then(function (token) {
resolve(true);
}, function (error) {
reject(false);
});
});
}
else {
this.authService.loginRedirect(this.config.consentScopes, this.config.extraQueryParameters);
}
}
}
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Promise {
this.authService.getLogger().verbose("location change event from old url to new url");
this.authService.updateDataFromCache([this.config.clientID]);
if (!this.authService._oauthData.isAuthenticated && this.isObjectEmpty(this.authService._oauthData.idToken)) {
if (state.url) {
if (!this.authService._renewActive && !this.authService.loginInProgress()) {
var loginStartPage = this.getBaseUrl() + state.url;
if (loginStartPage !== null) {
this.authService.getCacheStorage().setItem(Constants.angularLoginRequest, loginStartPage);
}
if (this.config.popUp) {
return this.authService.loginPopup(this.config.consentScopes, this.config.extraQueryParameters)
.then(function (token) {
return true;
}, function (error) {
return false;
});
}
else {
this.authService.loginRedirect(this.config.consentScopes, this.config.extraQueryParameters);
}
}
}
}
//token is expired/deleted but userdata still exists in _oauthData object