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 { ...@@ -214,7 +214,6 @@ export class EditIndividualsComponent implements OnInit {
} }
) )
} }
// this.updateGeographicSite();
} }
refreshIndividual(updatedIndividual: Individual) { refreshIndividual(updatedIndividual: Individual) {
...@@ -223,7 +222,6 @@ export class EditIndividualsComponent implements OnInit { ...@@ -223,7 +222,6 @@ export class EditIndividualsComponent implements OnInit {
if(this.testbedProvider) { if(this.testbedProvider) {
this.retrieveGeographicSite() this.retrieveGeographicSite()
} }
console.log("TODO-Retrieve Geographic Site info as well")//TODO
} }
retrieveGeographicSite(){ retrieveGeographicSite(){
......
...@@ -17,46 +17,24 @@ export class RedirectComponent implements OnInit { ...@@ -17,46 +17,24 @@ export class RedirectComponent implements OnInit {
) { } ) { }
ngOnInit() { 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') const activePortal = localStorage.getItem('active_portal')
if (activePortal === 'services') { if (activePortal === 'services') {
if (isTestbedProvider){
this.router.navigate(['services', 'individual_update'])
}
else {
// this.router.navigate(['services', 'services_marketplace'])
this.router.navigate(['services', 'individual_update']) this.router.navigate(['services', 'individual_update'])
}
} }
else if (activePortal === 'resources') { else if (activePortal === 'resources') {
this.router.navigate(['resources', 'resource_catalogs']) this.router.navigate(['resources', 'resource_catalogs'])
} }
else if (activePortal === 'testing') { else if (activePortal === 'testing') {
if (isTestbedProvider){
this.router.navigate(['testing', 'individual_update']) this.router.navigate(['testing', 'individual_update'])
} else {
this.router.navigate(['testing', 'service_test_specs'])
}
} }
else if (activePortal === 'products') { else if (activePortal === 'products') {
if (isTestbedProvider){
this.router.navigate(['products', 'individual_update']) this.router.navigate(['products', 'individual_update'])
} else {
this.router.navigate(['products', 'marketplace'])
}
} }
else { else {
......
...@@ -37,12 +37,12 @@ export class AuthService { ...@@ -37,12 +37,12 @@ export class AuthService {
public portalUser: Individual public portalUser: Individual
public portalUserJWT: userFromJWT public portalUserJWT: userFromJWT
constructor( constructor(
private oauthService: OAuthService, private oauthService: OAuthService,
private router: Router, private router: Router,
private bootstrapService: BootstrapService, private bootstrapService: BootstrapService,
private individualService: IndividualService private individualService: IndividualService
) )
{ {
window.addEventListener('storage', (event) => { window.addEventListener('storage', (event) => {
// The `key` is `null` if the event was caused by `.clear()` // The `key` is `null` if the event was caused by `.clear()`
...@@ -77,7 +77,7 @@ export class AuthService { ...@@ -77,7 +77,7 @@ export class AuthService {
public runInitialLoginSequence() { public runInitialLoginSequence() {
this.authConfigFile = this.bootstrapService.getConfig().OAUTH_CONFIG this.authConfigFile = this.bootstrapService.getConfig().OAUTH_CONFIG
this.oauthService.configure(this.authConfigFile); this.oauthService.configure(this.authConfigFile);
this.oauthService.setStorage(localStorage); this.oauthService.setStorage(localStorage);
...@@ -88,15 +88,15 @@ export class AuthService { ...@@ -88,15 +88,15 @@ export class AuthService {
this.oauthService.tryLoginCodeFlow() this.oauthService.tryLoginCodeFlow()
.catch(error => console.error(error)) .catch(error => console.error(error))
.then( .then(
() => { () => {
// console.warn('AccessTokenExpiration : ', new Date(this.oauthService.getAccessTokenExpiration()).toUTCString()); // console.warn('AccessTokenExpiration : ', new Date(this.oauthService.getAccessTokenExpiration()).toUTCString());
if (this.oauthService.hasValidAccessToken()) { if (this.oauthService.hasValidAccessToken()) {
// console.warn('this.oauthService.hasValidAccessToken() === true') // console.warn('this.oauthService.hasValidAccessToken() === true')
this.isAuthenticatedSubject$.next(this.oauthService.hasValidAccessToken()); this.isAuthenticatedSubject$.next(this.oauthService.hasValidAccessToken());
return Promise.resolve(); return Promise.resolve();
} }
//If Silent LOGIN isn't implemented //If Silent LOGIN isn't implemented
else { else {
// console.warn('this.oauthService.hasValidAccessToken() === false') // console.warn('this.oauthService.hasValidAccessToken() === false')
...@@ -108,12 +108,12 @@ export class AuthService { ...@@ -108,12 +108,12 @@ export class AuthService {
this.isDoneLoadingSubject$.next(true) this.isDoneLoadingSubject$.next(true)
} }
) )
.catch( error => { .catch( error => {
this.isDoneLoadingSubject$.next(true) this.isDoneLoadingSubject$.next(true)
}) })
} }
public fetchUserInfo() { public fetchUserInfo() {
this.portalUserJWT = decode(this.getAccessToken()) this.portalUserJWT = decode(this.getAccessToken())
this.individualService.retrieveIndividual({id:'myuser'}).subscribe( this.individualService.retrieveIndividual({id:'myuser'}).subscribe(
...@@ -126,23 +126,11 @@ export class AuthService { ...@@ -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() { public login() {
this.oauthService.initCodeFlow() this.oauthService.initCodeFlow()
} }
public logout() { public logout() {
// this.http.delete(authConfig.tokenEndpoint).subscribe( // this.http.delete(authConfig.tokenEndpoint).subscribe(
// data => console.log(data) // data => console.log(data)
// ) // )
...@@ -150,7 +138,7 @@ export class AuthService { ...@@ -150,7 +138,7 @@ export class AuthService {
localStorage.clear() localStorage.clear()
// this.http.delete(this.authConfigFile.tokenEndpoint).subscribe( // this.http.delete(this.authConfigFile.tokenEndpoint).subscribe(
// data => { // data => {
// console.warn(data) // console.warn(data)
// this.oauthService.logOut() // this.oauthService.logOut()
// this.router.navigate([this.router.routerState.snapshot.url]) // this.router.navigate([this.router.routerState.snapshot.url])
...@@ -158,7 +146,7 @@ export class AuthService { ...@@ -158,7 +146,7 @@ export class AuthService {
// error => { // error => {
// console.error(error) // console.error(error)
// this.oauthService.logOut() // 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