Compare commits

...

3 Commits

Author SHA1 Message Date
Sofia Papacharalampous ec77117f36 fixed redirect on wrong tenant url 2024-07-10 11:03:09 +03:00
Sofia Papacharalampous 0e2548e44d ui fix 2024-07-10 10:48:43 +03:00
Sofia Papacharalampous 922e73287c styling change 2024-07-10 09:41:45 +03:00
5 changed files with 16 additions and 6 deletions

View File

@ -43,6 +43,7 @@ import { TenantHandlingService } from './core/services/tenant/tenant-handling.se
import { GuidedTourModule } from './library/guided-tour/guided-tour.module';
import { DepositOauth2DialogModule } from './ui/misc/deposit-oauth2-dialog/deposit-oauth2-dialog.module';
import { OpenCDMPCustomTranslationCompiler } from './utilities/translate/opencdmp-custom-translation-compiler';
import { Router } from '@angular/router';
// AoT requires an exported function for factories
export function HttpLoaderFactory(languageHttpService: LanguageHttpService) {
@ -79,7 +80,7 @@ const cookieConfig: NgcCookieConsentConfig = {
type: 'info'
};
export function InstallationConfigurationFactory(appConfig: ConfigurationService, keycloak: KeycloakService, authService: AuthService, languageService: LanguageService, tenantHandlingService: TenantHandlingService) {
export function InstallationConfigurationFactory(appConfig: ConfigurationService, keycloak: KeycloakService, authService: AuthService, languageService: LanguageService, tenantHandlingService: TenantHandlingService, router: Router) {
return () => appConfig.loadConfiguration().then(() => {
return languageService.loadAvailableLanguages().toPromise();
}).then(x => keycloak.init({
@ -109,7 +110,14 @@ export function InstallationConfigurationFactory(appConfig: ConfigurationService
const tenantCode = tenantHandlingService.extractTenantCodeFromUrlPath(window.location.pathname) ?? authService.selectedTenant() ?? 'default';
const tokenPromise = keycloak.getToken();
return authService.prepareAuthRequest(from(tokenPromise), tenantCode, { params }).toPromise().catch(error => authService.onAuthenticateError(error));
return authService.prepareAuthRequest(from(tokenPromise), tenantCode, { params })
.toPromise()
.then(() => {
if (authService.selectedTenant() != tenantCode) {
router.navigate(['/']);
}
})
.catch(error => authService.onAuthenticateError(error));
}));
}
@ -157,7 +165,7 @@ export function InstallationConfigurationFactory(appConfig: ConfigurationService
{
provide: APP_INITIALIZER,
useFactory: InstallationConfigurationFactory,
deps: [ConfigurationService, KeycloakService, AuthService, LanguageService, TenantHandlingService],
deps: [ConfigurationService, KeycloakService, AuthService, LanguageService, TenantHandlingService, Router],
multi: true
},
{

View File

@ -174,7 +174,6 @@ export class AuthService extends BaseService {
return this.ensureTenant(tenantCode ?? this.selectedTenant() ?? 'default');
}),
concatMap(response => {
if (response == 'default' && tenantCode != 'default') throw Error();
return this.principalService.me(httpParams);
}),
concatMap(response => {

View File

@ -199,7 +199,7 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
}
public canEdit(descriptionTemplate: DescriptionTemplate): boolean {
return descriptionTemplate.status !== DescriptionTemplateStatus.Finalized && this.hasPermission(AppPermission.EditDescriptionTemplate, descriptionTemplate);
return descriptionTemplate.status !== DescriptionTemplateStatus.Finalized && this.hasPermission(AppPermission.EditDescriptionTemplate, descriptionTemplate) && descriptionTemplate.belongsToCurrentTenant;
}
public canCreateNew(): boolean {

View File

@ -40,6 +40,9 @@ export class LoginComponent extends BaseComponent implements OnInit {
this.authService.prepareAuthRequest(from(this.keycloakService.getToken()), tenantCode).pipe(takeUntil(this._destroyed)).subscribe(
() => {
let returnUrL = this.returnUrl;
if (this.authService.selectedTenant() != tenantCode) returnUrL = this.routerUtils.generateUrl('/');
this.zone.run(() => this.router.navigateByUrl(this.routerUtils.generateUrl(returnUrL)));
},
(error) => this.authService.authenticate('/'));

View File

@ -17,7 +17,7 @@
<div class="row align-items-center">
<div class="col-auto"><span class="plan-logo">{{ 'PLAN-OVERVIEW.TITLE' | translate }}</span></div>
<div class="col-auto pr-0 d-flex"><span class="plan-label">{{ plan.label }}</span></div>
<div class="col-auto pr-0"><span style="font-weight: 700;">.</span></div>
<div class="col-auto pr-0 mb-1"><span style="font-weight: 700;">.</span></div>
<div class="col-auto d-flex"><button mat-button [matMenuTriggerFor]="versions" style="border-radius: 100px; background-color: #eaeaea;">
<div class="pl-2 pr-1 d-flex align-items-center">{{'PLAN-OVERVIEW.VERSION' | translate}} {{selectedPlanVersion?.version}} <mat-icon class="ml-1">arrow_drop_down</mat-icon></div>
</button></div>