Skip to content
Snippets Groups Projects
Commit f7733648 authored by Labros Papadopoulos's avatar Labros Papadopoulos
Browse files

redirection logic

parent 56022ce9
No related branches found
No related tags found
1 merge request!11Party registration workflow
Pipeline #6253 passed
......@@ -214,7 +214,6 @@ export class EditIndividualsComponent implements OnInit {
}
)
}
// this.updateGeographicSite();
}
refreshIndividual(updatedIndividual: Individual) {
......@@ -223,7 +222,6 @@ export class EditIndividualsComponent implements OnInit {
if(this.testbedProvider) {
this.retrieveGeographicSite()
}
console.log("TODO-Retrieve Geographic Site info as well")//TODO
}
retrieveGeographicSite(){
......
......@@ -17,46 +17,24 @@ export class RedirectComponent implements OnInit {
) { }
ngOnInit() {
// this.authService.fetchIndividualInfo();
let isTestbedProvider = false;
if(this.authService != null && this.authService.portalUserJWT !=null) {
for(var val of this.authService.portalUserJWT.realm_access.roles){
if (val ==='TESTBED_PROVIDER') {
isTestbedProvider=true
}
}}
//TODO insert redirection logic
const activePortal = localStorage.getItem('active_portal')
if (activePortal === 'services') {
if (isTestbedProvider){
this.router.navigate(['services', 'individual_update'])
}
else {
// this.router.navigate(['services', 'services_marketplace'])
this.router.navigate(['services', 'individual_update'])
}
}
else if (activePortal === 'resources') {
this.router.navigate(['resources', 'resource_catalogs'])
}
else if (activePortal === 'testing') {
if (isTestbedProvider){
this.router.navigate(['testing', 'individual_update'])
} else {
this.router.navigate(['testing', 'service_test_specs'])
}
}
else if (activePortal === 'products') {
if (isTestbedProvider){
this.router.navigate(['products', 'individual_update'])
} else {
this.router.navigate(['products', 'marketplace'])
}
}
else {
......
......@@ -37,12 +37,12 @@ export class AuthService {
public portalUser: Individual
public portalUserJWT: userFromJWT
constructor(
constructor(
private oauthService: OAuthService,
private router: Router,
private bootstrapService: BootstrapService,
private individualService: IndividualService
)
)
{
window.addEventListener('storage', (event) => {
// The `key` is `null` if the event was caused by `.clear()`
......@@ -77,7 +77,7 @@ export class AuthService {
public runInitialLoginSequence() {
this.authConfigFile = this.bootstrapService.getConfig().OAUTH_CONFIG
this.oauthService.configure(this.authConfigFile);
this.oauthService.setStorage(localStorage);
......@@ -88,15 +88,15 @@ export class AuthService {
this.oauthService.tryLoginCodeFlow()
.catch(error => console.error(error))
.then(
() => {
() => {
// console.warn('AccessTokenExpiration : ', new Date(this.oauthService.getAccessTokenExpiration()).toUTCString());
if (this.oauthService.hasValidAccessToken()) {
// console.warn('this.oauthService.hasValidAccessToken() === true')
this.isAuthenticatedSubject$.next(this.oauthService.hasValidAccessToken());
return Promise.resolve();
}
}
//If Silent LOGIN isn't implemented
else {
// console.warn('this.oauthService.hasValidAccessToken() === false')
......@@ -108,12 +108,12 @@ export class AuthService {
this.isDoneLoadingSubject$.next(true)
}
)
.catch( error => {
.catch( error => {
this.isDoneLoadingSubject$.next(true)
})
}
public fetchUserInfo() {
this.portalUserJWT = decode(this.getAccessToken())
this.individualService.retrieveIndividual({id:'myuser'}).subscribe(
......@@ -126,23 +126,11 @@ export class AuthService {
)
}
public fetchIndividualInfo() {
// this.portalUserJWT = decode(this.getAccessToken())
this.individualService.retrieveIndividual({id:'myuser'}).subscribe(
data => { this.portalUser = data },
error => {
console.error(error)
// this.toast.error('An error occurred fetching user information')
// this.logout()
}
)
}
public login() {
this.oauthService.initCodeFlow()
}
public logout() {
public logout() {
// this.http.delete(authConfig.tokenEndpoint).subscribe(
// data => console.log(data)
// )
......@@ -150,7 +138,7 @@ export class AuthService {
localStorage.clear()
// this.http.delete(this.authConfigFile.tokenEndpoint).subscribe(
// data => {
// data => {
// console.warn(data)
// this.oauthService.logOut()
// this.router.navigate([this.router.routerState.snapshot.url])
......@@ -158,7 +146,7 @@ export class AuthService {
// error => {
// console.error(error)
// this.oauthService.logOut()
// this.router.navigate([this.router.routerState.snapshot.url])
// this.router.navigate([this.router.routerState.snapshot.url])
// }
// )
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment