From f05962a3b2abc292789dd2122affa575d070fd04 Mon Sep 17 00:00:00 2001 From: sgiannopoulos Date: Fri, 31 May 2024 14:07:23 +0300 Subject: [PATCH] login and tenant ui fixes --- .../src/app/core/admin-auth-guard.service.ts | 33 ----- .../src/app/core/core-service.module.ts | 5 - .../app/core/services/auth/auth.service.ts | 4 +- .../core/services/http/principal.service.ts | 1 - .../app/core/special-auth-guard.service.ts | 55 --------- .../maintenance-tasks.routing.ts | 6 +- .../prefilling-source.routing.ts | 1 - .../reference-type/reference-type.routing.ts | 5 +- .../ui/admin/reference/reference.routing.ts | 1 - .../src/app/ui/admin/tenant/tenant.routing.ts | 1 - .../src/app/ui/auth/login/login.component.ts | 39 ++++-- .../src/app/ui/auth/login/login.module.ts | 4 +- .../src/app/ui/auth/login/login.routing.ts | 10 +- .../post-login/post-login.component.html | 38 ------ .../post-login/post-login.component.scss | 17 --- .../login/post-login/post-login.component.ts | 113 ------------------ .../ui/auth/login/utilities/login.service.ts | 2 +- .../supportive-material-editor.routing.ts | 4 +- .../tenant-switch/tenant-switch.component.ts | 36 +++--- .../interceptors/status-code.interceptor.ts | 16 +-- .../notification-template.routing.ts | 1 - 21 files changed, 74 insertions(+), 318 deletions(-) delete mode 100644 dmp-frontend/src/app/core/admin-auth-guard.service.ts delete mode 100644 dmp-frontend/src/app/core/special-auth-guard.service.ts delete mode 100644 dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.html delete mode 100644 dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.scss delete mode 100644 dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.ts diff --git a/dmp-frontend/src/app/core/admin-auth-guard.service.ts b/dmp-frontend/src/app/core/admin-auth-guard.service.ts deleted file mode 100644 index 5126fba2c..000000000 --- a/dmp-frontend/src/app/core/admin-auth-guard.service.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot } from '@angular/router'; -import { AuthService } from './services/auth/auth.service'; -import { AppRole } from './common/enum/app-role'; - -@Injectable() -export class AdminAuthGuard implements CanActivate, CanLoad { - constructor(private auth: AuthService, private router: Router) { - } - - isAdmin(): boolean { - if (!this.auth.currentAccountIsAuthenticated()) { return false; } - return this.auth.hasRole(AppRole.Admin); - } - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - const url: string = state.url; - if (!this.isAdmin()) { - this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } }); - return false; - } - return true; - } - - canLoad(route: Route): boolean { - const url = `/${route.path}`; - if (!this.isAdmin()) { - this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } }); - return false; - } - return true; - } -} diff --git a/dmp-frontend/src/app/core/core-service.module.ts b/dmp-frontend/src/app/core/core-service.module.ts index f6a971f11..419e551ab 100644 --- a/dmp-frontend/src/app/core/core-service.module.ts +++ b/dmp-frontend/src/app/core/core-service.module.ts @@ -1,6 +1,5 @@ import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; import { CookieService } from 'ngx-cookie-service'; -import { AdminAuthGuard } from './admin-auth-guard.service'; import { AuthGuard } from './auth-guard.service'; import { AuthService } from './services/auth/auth.service'; import { ContactSupportService } from './services/contact-support/contact-support.service'; @@ -20,8 +19,6 @@ import { ProgressIndicationService } from './services/progress-indication/progre import { TimezoneService } from './services/timezone/timezone-service'; import { CollectionUtils } from './services/utilities/collection-utils.service'; import { TypeUtils } from './services/utilities/type-utils.service'; -import { SpecialAuthGuard } from './special-auth-guard.service'; -//import { KeycloakService } from 'keycloak-angular'; import { CanDeactivateGuard } from '@app/library/deactivate/can-deactivate.guard'; import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service'; import { FilterService } from '@common/modules/text-filter/filter-service'; @@ -70,8 +67,6 @@ export class CoreServiceModule { AuthService, CookieService, BaseHttpV2Service, - AdminAuthGuard, - SpecialAuthGuard, AuthGuard, CultureService, TimezoneService, diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index 1eb9a9dbe..547473319 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -279,7 +279,7 @@ export class AuthService extends BaseService { }) .catch((error) => this.onAuthenticateError(error)); } else { - this.zone.run(() => this.router.navigate([returnUrl])); + this.zone.run(() => this.router.navigateByUrl(returnUrl)); } } @@ -327,7 +327,7 @@ export class AuthService extends BaseService { this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-LOGIN'), SnackBarNotificationLevel.Success ); - this.zone.run(() => this.router.navigate([returnUrl])); + this.zone.run(() => this.router.navigateByUrl(returnUrl)); } onAuthenticateSuccessReload(): void { diff --git a/dmp-frontend/src/app/core/services/http/principal.service.ts b/dmp-frontend/src/app/core/services/http/principal.service.ts index a5538a027..efb453729 100644 --- a/dmp-frontend/src/app/core/services/http/principal.service.ts +++ b/dmp-frontend/src/app/core/services/http/principal.service.ts @@ -3,7 +3,6 @@ import { AppAccount } from '@app/core/model/auth/principal'; import { Observable } from 'rxjs'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; -import { map } from 'rxjs/operators'; import { Tenant } from '@app/core/model/tenant/tenant'; @Injectable() diff --git a/dmp-frontend/src/app/core/special-auth-guard.service.ts b/dmp-frontend/src/app/core/special-auth-guard.service.ts deleted file mode 100644 index 53d90fe02..000000000 --- a/dmp-frontend/src/app/core/special-auth-guard.service.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot } from '@angular/router'; -import { AuthService } from './services/auth/auth.service'; -import { AppRole } from './common/enum/app-role'; - -@Injectable() -export class SpecialAuthGuard implements CanActivate, CanLoad { - constructor(private auth: AuthService, private router: Router) { - } - - hasPermission(permission: AppRole): boolean { - if (!this.auth.currentAccountIsAuthenticated()) { return false; } - return this.auth.hasRole(permission); - } - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - const url: string = state.url; - const permissions = route.data['authContext']['permissions']; - let count = permissions.length; - if (count < 0 || count === undefined) { - return false; - } - for (let i = 0; i < permissions.length; i++) { - if (!this.hasPermission(permissions[i])) { - count--; - } - } - if (count === 0) { - this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } }); - return false; - } else { - return true; - } - } - - canLoad(route: Route): boolean { - const url = `/${route.path}`; - const permissions = route.data['authContext']['permissions']; - let count = permissions.length; - if (count < 0 || count === undefined) { - return false; - } - for (let i = 0; i < permissions.length; i++) { - if (!this.hasPermission(permissions[i])) { - count--; - } - } - if (count === 0) { - this.router.navigate(['/unauthorized'], { queryParams: { returnUrl: url } }); - return false; - } else { - return true; - } - } -} diff --git a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.routing.ts b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.routing.ts index daec08ac0..6d43e8ac8 100644 --- a/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.routing.ts +++ b/dmp-frontend/src/app/ui/admin/maintenance-tasks/maintenance-tasks.routing.ts @@ -1,15 +1,15 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { MaintenanceTasksComponent } from './maintenance-tasks.component'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; +import { AuthGuard } from '@app/core/auth-guard.service'; const routes: Routes = [ - { path: '', component: MaintenanceTasksComponent, canActivate: [AdminAuthGuard] }, + { path: '', component: MaintenanceTasksComponent, canActivate: [AuthGuard] }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) -export class MaintenanceTasksRoutingModule { } \ No newline at end of file +export class MaintenanceTasksRoutingModule { } diff --git a/dmp-frontend/src/app/ui/admin/prefilling-source/prefilling-source.routing.ts b/dmp-frontend/src/app/ui/admin/prefilling-source/prefilling-source.routing.ts index 0a22d62b3..9163aa9eb 100644 --- a/dmp-frontend/src/app/ui/admin/prefilling-source/prefilling-source.routing.ts +++ b/dmp-frontend/src/app/ui/admin/prefilling-source/prefilling-source.routing.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; import { PrefillingSourceEditorComponent } from './editor/prefilling-source-editor.component'; import { PrefillingSourceListingComponent } from './listing/prefilling-source-listing.component'; import { AppPermission } from '@app/core/common/enum/permission.enum'; diff --git a/dmp-frontend/src/app/ui/admin/reference-type/reference-type.routing.ts b/dmp-frontend/src/app/ui/admin/reference-type/reference-type.routing.ts index 8b13bdf31..08a531f10 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/reference-type.routing.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/reference-type.routing.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; import { ReferenceTypeEditorComponent } from './editor/reference-type-editor.component'; import { ReferenceTypeListingComponent } from './listing/reference-type-listing.component'; import { AuthGuard } from '@app/core/auth-guard.service'; @@ -16,8 +15,8 @@ const routes: Routes = [ component: ReferenceTypeListingComponent, canActivate: [AuthGuard] }, - { - path: 'new', + { + path: 'new', component: ReferenceTypeEditorComponent, canActivate: [AuthGuard], canDeactivate: [PendingChangesGuard], diff --git a/dmp-frontend/src/app/ui/admin/reference/reference.routing.ts b/dmp-frontend/src/app/ui/admin/reference/reference.routing.ts index 357e6b33c..0306ef868 100644 --- a/dmp-frontend/src/app/ui/admin/reference/reference.routing.ts +++ b/dmp-frontend/src/app/ui/admin/reference/reference.routing.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; import { ReferenceEditorComponent } from './editor/reference-editor.component'; import { ReferenceListingComponent } from './listing/reference-listing.component'; import { AppPermission } from '@app/core/common/enum/permission.enum'; diff --git a/dmp-frontend/src/app/ui/admin/tenant/tenant.routing.ts b/dmp-frontend/src/app/ui/admin/tenant/tenant.routing.ts index 4a24a3228..4a3efd541 100644 --- a/dmp-frontend/src/app/ui/admin/tenant/tenant.routing.ts +++ b/dmp-frontend/src/app/ui/admin/tenant/tenant.routing.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; import { TenantEditorComponent } from './editor/tenant-editor.component'; import { TenantListingComponent } from './listing/tenant-listing.component'; import { AppPermission } from '@app/core/common/enum/permission.enum'; diff --git a/dmp-frontend/src/app/ui/auth/login/login.component.ts b/dmp-frontend/src/app/ui/auth/login/login.component.ts index eebd9aaca..48ff6a507 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.component.ts @@ -1,7 +1,10 @@ import { Component, Input, NgZone, OnInit } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { AuthService } from '@app/core/services/auth/auth.service'; +import { PrincipalService } from '@app/core/services/http/principal.service'; import { BaseComponent } from '@common/base/base.component'; +import { BaseHttpParams } from '@common/http/base-http-params'; +import { InterceptorType } from '@common/http/interceptors/interceptor-type'; import { KeycloakService } from 'keycloak-angular'; import { from } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -24,6 +27,7 @@ export class LoginComponent extends BaseComponent implements OnInit { private router: Router, private authService: AuthService, private route: ActivatedRoute, + private principalService: PrincipalService, private keycloakService: KeycloakService ) { super(); } @@ -35,13 +39,34 @@ export class LoginComponent extends BaseComponent implements OnInit { if (!this.authService.selectedTenant()) { this.authService.selectedTenant('default'); } - this.authService.prepareAuthRequest(from(this.keycloakService.getToken())).pipe(takeUntil(this._destroyed)).subscribe( - () => { - let returnUrL = this.returnUrl; - let queryParams: Params = {}; - this.zone.run(() => this.router.navigate([returnUrL], { queryParams })); - }, - (error) => this.authService.authenticate('/')); + const params = new BaseHttpParams(); + params.interceptorContext = { + excludedInterceptors: [InterceptorType.TenantHeaderInterceptor] + }; + this.principalService.myTenants({ params: params }).subscribe(myTenants => { + if (myTenants) { + if (this.authService.selectedTenant()) { + if (myTenants.findIndex(x => x.code.toLocaleLowerCase() == this.authService.selectedTenant().toLocaleLowerCase()) < 0) { + this.authService.selectedTenant(null); + } + } + if (!this.authService.selectedTenant()) { + if (myTenants.length > 0) { + this.authService.selectedTenant(myTenants[0]?.code); + } + } + } else { + this.authService.selectedTenant(null); + } + + this.authService.prepareAuthRequest(from(this.keycloakService.getToken())).pipe(takeUntil(this._destroyed)).subscribe( + () => { + let returnUrL = this.returnUrl; + this.zone.run(() => this.router.navigateByUrl(returnUrL)); + }, + (error) => this.authService.authenticate('/')); + }, (error) => this.authService.authenticate('/')); + } } diff --git a/dmp-frontend/src/app/ui/auth/login/login.module.ts b/dmp-frontend/src/app/ui/auth/login/login.module.ts index 6546559d7..ff8dd384e 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.module.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.module.ts @@ -6,7 +6,6 @@ import { CommonFormsModule } from '@common/forms/common-forms.module'; import { CommonUiModule } from '@common/ui/common-ui.module'; import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component'; import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component'; -import { PostLoginComponent } from './post-login/post-login.component'; @NgModule({ imports: [ @@ -17,8 +16,7 @@ import { PostLoginComponent } from './post-login/post-login.component'; declarations: [ LoginComponent, MergeEmailConfirmation, - UnlinkEmailConfirmation, - PostLoginComponent + UnlinkEmailConfirmation ], exports: [ LoginComponent diff --git a/dmp-frontend/src/app/ui/auth/login/login.routing.ts b/dmp-frontend/src/app/ui/auth/login/login.routing.ts index 7beaba215..4ce9ef53d 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.routing.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.routing.ts @@ -4,7 +4,7 @@ import { LoginComponent } from './login.component'; import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component'; import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component'; import { AuthGuard } from '@app/core/auth-guard.service'; -import { PostLoginComponent } from './post-login/post-login.component'; +// import { PostLoginComponent } from './post-login/post-login.component'; const routes: Routes = [ { path: '', component: LoginComponent }, @@ -13,10 +13,10 @@ const routes: Routes = [ component: MergeEmailConfirmation, canActivate: [AuthGuard] }, - { - path: 'post', - component: PostLoginComponent - }, + // { + // path: 'post', + // component: PostLoginComponent + // }, { path: 'unlink/confirmation/:token', component: UnlinkEmailConfirmation }, ]; diff --git a/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.html b/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.html deleted file mode 100644 index c6ff1820d..000000000 --- a/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.html +++ /dev/null @@ -1,38 +0,0 @@ -
-
-
- - -

{{'TENANT-CHOOSE-DIALOG.TITLE' | translate}}

-
- -
-
- - {{'TENANT-CHOOSE-DIALOG.FIELDS.TENANT-CODE' | translate}} - - - {{tenant.code}} - - - {{formGroup.get('tenantCode').getError('backendError')?.message}} - {{'COMMONS.VALIDATION.REQUIRED' | translate}} - -
-
-
-
- -
-
- - -
-
-
-
-
-
-
-
-
diff --git a/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.scss b/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.scss deleted file mode 100644 index 7d0c86080..000000000 --- a/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.scss +++ /dev/null @@ -1,17 +0,0 @@ -.tenant-choose-dialog { - padding-top: 1em; - - .editor-actions { - margin-top: 30px; - } - - .confirmation-message { - padding-bottom: 1rem; - font-size: 0.8rem; - } - - .display-flex { - display: flex; - font-size: 0.8rem !important; - } -} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.ts b/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.ts deleted file mode 100644 index bf72c9cc5..000000000 --- a/dmp-frontend/src/app/ui/auth/login/post-login/post-login.component.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; -import { ActivatedRoute, Router } from '@angular/router'; -import { Tenant } from '@app/core/model/tenant/tenant'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; -import { PrincipalService } from '@app/core/services/http/principal.service'; -import { BaseComponent } from '@common/base/base.component'; -import { FormService } from '@common/forms/form-service'; -import { BaseHttpParams } from '@common/http/base-http-params'; -import { InterceptorType } from '@common/http/interceptors/interceptor-type'; -import { KeycloakService } from 'keycloak-angular'; -import { from } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - templateUrl: './post-login.component.html', - styleUrls: ['./post-login.component.scss'], -}) -export class PostLoginComponent extends BaseComponent implements OnInit { - formGroup: UntypedFormGroup = null; - protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); - - protected tenants: Partial[] = []; - protected selectedTenant = null; - - returnUrl: string; - - constructor( - private formService: FormService, - private route: ActivatedRoute, - private router: Router, - protected installationConfiguration: ConfigurationService, - private authService: AuthService, - private keycloakService: KeycloakService, - private principalService: PrincipalService - ) { - super(); - } - - ngOnInit(): void { - this.formGroup = this.formBuilder.group({ - tenantCode: ['', [Validators.required]] - }); - if (this.authService.hasAccessToken()) { - this.loadUserTenants(); - } else { - this.keycloakService.getToken().then(token => { - this.authService.currentAuthenticationToken(token); - this.loadUserTenants(); - }); - } - } - - loadUserTenants() { - const params = new BaseHttpParams(); - params.interceptorContext = { - excludedInterceptors: [InterceptorType.TenantHeaderInterceptor] - }; - if (this.authService.selectedTenant()) { - this.loadUser(); - return; - } - this.principalService.myTenants({ params: params }).subscribe(myTenants => { - if (myTenants) { - if (myTenants.length > 1) { - this.tenants = myTenants; - } else if (myTenants.length === 1) { - this.authService.selectedTenant(myTenants[0]?.code); - this.loadUser(); - } else { - this.authService.selectedTenant(null); - //this.loadUser(); - } - } else { - this.authService.selectedTenant(null); - //this.loadUser(); - } - }); - } - - loadUser(): void { - const returnUrl = '/home'; - // const returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || '/home'; - this.authService.prepareAuthRequest(from(this.keycloakService.getToken()), {}).pipe(takeUntil(this._destroyed)).subscribe(() => this.authService.onAuthenticateSuccess(returnUrl), (error) => this.authService.onAuthenticateError(error)); - } - - save(e: Event): void { - e.preventDefault(); - this.formSubmit(); - this.loadUser(); - } - - cancel(): void { - this.router.navigate(['/logout']); - } - - formSubmit(): void { - this.formService.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } - - this.selectedTenant = this.formGroup.value['tenantCode']; - this.authService.selectedTenant(this.selectedTenant); - } - - public isFormValid(): Boolean { - return this.formGroup.valid; - } - - clearErrorModel() { - this.formService.validateAllFormFields(this.formGroup); - } -} diff --git a/dmp-frontend/src/app/ui/auth/login/utilities/login.service.ts b/dmp-frontend/src/app/ui/auth/login/utilities/login.service.ts index 92d20dd58..8534c1d59 100644 --- a/dmp-frontend/src/app/ui/auth/login/utilities/login.service.ts +++ b/dmp-frontend/src/app/ui/auth/login/utilities/login.service.ts @@ -51,7 +51,7 @@ export class LoginService extends BaseService { if (this.authService.currentAccountIsAuthenticated() && this.authService.getUserProfileCulture()) { this.cultureService.cultureSelected(this.authService.getUserProfileCulture()); } if (this.authService.currentAccountIsAuthenticated() && this.authService.getUserProfileLanguage()) { this.language.changeLanguage(this.authService.getUserProfileLanguage()); } const redirectUrl = returnUrl || '/'; - this.router.navigate([redirectUrl]); + this.zone.run(() => this.router.navigateByUrl(redirectUrl)); }); } diff --git a/dmp-frontend/src/app/ui/supportive-material-editor/supportive-material-editor.routing.ts b/dmp-frontend/src/app/ui/supportive-material-editor/supportive-material-editor.routing.ts index cd8c22d0c..fc6d2b6e1 100644 --- a/dmp-frontend/src/app/ui/supportive-material-editor/supportive-material-editor.routing.ts +++ b/dmp-frontend/src/app/ui/supportive-material-editor/supportive-material-editor.routing.ts @@ -1,11 +1,11 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { SupportiveMaterialEditorComponent } from './supportive-material-editor.component'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; +import { AuthGuard } from '@app/core/auth-guard.service'; const routes: Routes = [ - { path: '', component: SupportiveMaterialEditorComponent, canActivate: [AdminAuthGuard] }, + { path: '', component: SupportiveMaterialEditorComponent, canActivate: [AuthGuard] }, ]; @NgModule({ diff --git a/dmp-frontend/src/app/ui/tenant/tenant-switch/tenant-switch.component.ts b/dmp-frontend/src/app/ui/tenant/tenant-switch/tenant-switch.component.ts index 8c28a854a..9ae9c13eb 100644 --- a/dmp-frontend/src/app/ui/tenant/tenant-switch/tenant-switch.component.ts +++ b/dmp-frontend/src/app/ui/tenant/tenant-switch/tenant-switch.component.ts @@ -12,32 +12,32 @@ import { Observable, from } from "rxjs"; import { takeUntil } from "rxjs/operators"; @Component({ - selector: 'app-tenant-switch', - templateUrl: 'tenant-switch.component.html', - styleUrls: ['tenant-switch.component.scss'] + selector: 'app-tenant-switch', + templateUrl: 'tenant-switch.component.html', + styleUrls: ['tenant-switch.component.scss'] }) export class TenantSwitchComponent extends BaseComponent implements OnInit { tenants: Observable>; constructor( private router: Router, - private keycloakService: KeycloakService, - private principalService: PrincipalService, + private keycloakService: KeycloakService, + private principalService: PrincipalService, private authService: AuthService, ) { super(); } - get currentTenant(): string { - return this.authService.selectedTenant(); - } + get currentTenant(): string { + return this.authService.selectedTenant(); + } ngOnInit() { this.tenants = this.loadUserTenants(); //TODO //this.tenantChange.emit(this.getCurrentLanguage()) } - loadUserTenants(): Observable> { + loadUserTenants(): Observable> { const params = new BaseHttpParams(); params.interceptorContext = { excludedInterceptors: [InterceptorType.TenantHeaderInterceptor] @@ -46,9 +46,9 @@ export class TenantSwitchComponent extends BaseComponent implements OnInit { } onTenantSelected(selectedTenant: MatButtonToggleChange) { - if (selectedTenant.value === undefined || selectedTenant.value === '') return; + if (selectedTenant.value === undefined || selectedTenant.value === '') return; - this.formSubmit(selectedTenant.value); + this.formSubmit(selectedTenant.value); this.loadUser(); } @@ -58,12 +58,12 @@ export class TenantSwitchComponent extends BaseComponent implements OnInit { loadUser(): void { this.authService.prepareAuthRequest(from(this.keycloakService.getToken()), {}) - .pipe(takeUntil(this._destroyed)) - .subscribe( - () => { - this.authService.onAuthenticateSuccessReload(); - }, - (error) => this.authService.onAuthenticateError(error) - ); + .pipe(takeUntil(this._destroyed)) + .subscribe( + () => { + this.authService.onAuthenticateSuccessReload(); + }, + (error) => this.authService.onAuthenticateError(error) + ); } } diff --git a/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts b/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts index 809659444..9e737cae8 100644 --- a/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts +++ b/dmp-frontend/src/common/http/interceptors/status-code.interceptor.ts @@ -16,14 +16,14 @@ export class StatusCodeInterceptor extends BaseInterceptor { type: InterceptorType; interceptRequest(req: HttpRequest, next: HttpHandler): Observable> { return next.handle(req).pipe(tap(event => { }, err => { - if (err.status === 480) { - this.router.navigate(['confirmation']); - } - const error: HttpError = this.httpErrorHandlingService.getError(err); - if (error.statusCode === 403 && error.errorCode === 103) { - this.authService.selectedTenant('default'); - this.router.navigate(['/']); - } + // if (err.status === 480) { + // this.router.navigate(['confirmation']); + // } + // const error: HttpError = this.httpErrorHandlingService.getError(err); + // if (error.statusCode === 403 && error.errorCode === 103) { + // this.authService.selectedTenant('default'); + // this.router.navigate(['/']); + // } })); } diff --git a/dmp-frontend/src/notification-service/ui/admin/notification-template/notification-template.routing.ts b/dmp-frontend/src/notification-service/ui/admin/notification-template/notification-template.routing.ts index 9c3fef1ec..ca4a0ccc2 100644 --- a/dmp-frontend/src/notification-service/ui/admin/notification-template/notification-template.routing.ts +++ b/dmp-frontend/src/notification-service/ui/admin/notification-template/notification-template.routing.ts @@ -1,6 +1,5 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AdminAuthGuard } from '@app/core/admin-auth-guard.service'; import { AppPermission } from '@app/core/common/enum/permission.enum'; import { AuthGuard } from '@app/core/auth-guard.service'; import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';