Removed app state guard
This commit is contained in:
parent
d3d8b16f8e
commit
f6da0da6de
@ -16,7 +16,6 @@
|
|||||||
"@components/**",
|
"@components/**",
|
||||||
"@guards/**",
|
"@guards/**",
|
||||||
"@i18n/**",
|
"@i18n/**",
|
||||||
"@state/**",
|
|
||||||
"@utils/**",
|
"@utils/**",
|
||||||
"@models/**",
|
"@models/**",
|
||||||
"@environments/**",
|
"@environments/**",
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import { BaseScreenComponent } from '@components/base-screen/base-screen.compone
|
|||||||
import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router';
|
import { RouteReuseStrategy, RouterModule, Routes } from '@angular/router';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { DownloadsListScreenComponent } from '@components/downloads-list-screen/downloads-list-screen.component';
|
import { DownloadsListScreenComponent } from '@components/downloads-list-screen/downloads-list-screen.component';
|
||||||
import { AppStateGuard } from '@state/app-state.guard';
|
|
||||||
import { DossiersGuard } from '@guards/dossiers.guard';
|
import { DossiersGuard } from '@guards/dossiers.guard';
|
||||||
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
|
import { DossierTemplatesGuard } from '@guards/dossier-templates.guard';
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ const routes: Routes = [
|
|||||||
loadChildren: () => import('./modules/dossier/dossiers.module').then(m => m.DossiersModule),
|
loadChildren: () => import('./modules/dossier/dossiers.module').then(m => m.DossiersModule),
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, DossierTemplatesGuard, AppStateGuard, DossiersGuard],
|
routeGuards: [AuthGuard, RedRoleGuard, DossierTemplatesGuard, DossiersGuard],
|
||||||
requiredRoles: ['RED_USER', 'RED_MANAGER'],
|
requiredRoles: ['RED_USER', 'RED_MANAGER'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -52,7 +51,7 @@ const routes: Routes = [
|
|||||||
],
|
],
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,13 +1,22 @@
|
|||||||
import { Component, ViewContainerRef } from '@angular/core';
|
import { Component, OnInit, ViewContainerRef } from '@angular/core';
|
||||||
import { RouterHistoryService } from '@services/router-history.service';
|
import { RouterHistoryService } from '@services/router-history.service';
|
||||||
|
import { UserService } from '@services/user.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-root',
|
selector: 'redaction-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss'],
|
styleUrls: ['./app.component.scss'],
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit {
|
||||||
// ViewContainerRef needs to be injected for the color picker to work
|
// ViewContainerRef needs to be injected for the color picker to work
|
||||||
// RouterHistoryService needs to be injected for last dossiers screen to be updated on first app load
|
// RouterHistoryService needs to be injected for last dossiers screen to be updated on first app load
|
||||||
constructor(public viewContainerRef: ViewContainerRef, private readonly _routerHistoryService: RouterHistoryService) {}
|
constructor(
|
||||||
|
public viewContainerRef: ViewContainerRef,
|
||||||
|
private readonly _routerHistoryService: RouterHistoryService,
|
||||||
|
private readonly _userService: UserService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async ngOnInit(): Promise<void> {
|
||||||
|
await this._userService.initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
apps/red-ui/src/app/guards/dictionary-exists.guard.ts
Normal file
21
apps/red-ui/src/app/guards/dictionary-exists.guard.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
|
||||||
|
import { DICTIONARY_TYPE, DOSSIER_TEMPLATE_ID } from '@utils/constants';
|
||||||
|
import { DictionariesMapService } from '../services/entity-services/dictionaries-map.service';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class DictionaryExistsGuard implements CanActivate {
|
||||||
|
constructor(private readonly _dictionariesMapService: DictionariesMapService, private readonly _router: Router) {}
|
||||||
|
|
||||||
|
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
|
||||||
|
const dossierTemplateId: string = route.paramMap.get(DOSSIER_TEMPLATE_ID);
|
||||||
|
const type: string = route.paramMap.get(DICTIONARY_TYPE);
|
||||||
|
|
||||||
|
if (!this._dictionariesMapService.get(dossierTemplateId, type)) {
|
||||||
|
await this._router.navigate(['main', 'admin', 'dossier-templates', dossierTemplateId, 'dictionaries']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
apps/red-ui/src/app/guards/dossier-template-exists.guard.ts
Normal file
20
apps/red-ui/src/app/guards/dossier-template-exists.guard.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
|
||||||
|
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||||
|
import { DOSSIER_TEMPLATE_ID } from '@utils/constants';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class DossierTemplateExistsGuard implements CanActivate {
|
||||||
|
constructor(private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _router: Router) {}
|
||||||
|
|
||||||
|
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
|
||||||
|
const dossierTemplateId: string = route.paramMap.get(DOSSIER_TEMPLATE_ID);
|
||||||
|
|
||||||
|
if (!this._dossierTemplatesService.find(dossierTemplateId)) {
|
||||||
|
await this._router.navigate(['main', 'admin', 'dossier-templates']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,7 +3,6 @@ import { RouterModule } from '@angular/router';
|
|||||||
import { CompositeRouteGuard } from '@iqser/common-ui';
|
import { CompositeRouteGuard } from '@iqser/common-ui';
|
||||||
import { AuthGuard } from '../auth/auth.guard';
|
import { AuthGuard } from '../auth/auth.guard';
|
||||||
import { RedRoleGuard } from '../auth/red-role.guard';
|
import { RedRoleGuard } from '../auth/red-role.guard';
|
||||||
import { AppStateGuard } from '@state/app-state.guard';
|
|
||||||
import { BaseAccountScreenComponent } from './base-account-screen/base-account-screen-component';
|
import { BaseAccountScreenComponent } from './base-account-screen/base-account-screen-component';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
@ -13,7 +12,7 @@ const routes = [
|
|||||||
component: BaseAccountScreenComponent,
|
component: BaseAccountScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
loadChildren: () => import('./screens/user-profile/user-profile.module').then(m => m.UserProfileModule),
|
loadChildren: () => import('./screens/user-profile/user-profile.module').then(m => m.UserProfileModule),
|
||||||
},
|
},
|
||||||
@ -22,7 +21,7 @@ const routes = [
|
|||||||
component: BaseAccountScreenComponent,
|
component: BaseAccountScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_USER'],
|
requiredRoles: ['RED_USER'],
|
||||||
},
|
},
|
||||||
loadChildren: () => import('./screens/notifications/notifications.module').then(m => m.NotificationsModule),
|
loadChildren: () => import('./screens/notifications/notifications.module').then(m => m.NotificationsModule),
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { NgModule } from '@angular/core';
|
|||||||
import { AuthGuard } from '../auth/auth.guard';
|
import { AuthGuard } from '../auth/auth.guard';
|
||||||
import { CompositeRouteGuard } from '@iqser/common-ui';
|
import { CompositeRouteGuard } from '@iqser/common-ui';
|
||||||
import { RedRoleGuard } from '../auth/red-role.guard';
|
import { RedRoleGuard } from '../auth/red-role.guard';
|
||||||
import { AppStateGuard } from '@state/app-state.guard';
|
|
||||||
import { DictionaryListingScreenComponent } from './screens/dictionary-listing/dictionary-listing-screen.component';
|
import { DictionaryListingScreenComponent } from './screens/dictionary-listing/dictionary-listing-screen.component';
|
||||||
import { DictionaryOverviewScreenComponent } from './screens/dictionary-overview/dictionary-overview-screen.component';
|
import { DictionaryOverviewScreenComponent } from './screens/dictionary-overview/dictionary-overview-screen.component';
|
||||||
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
|
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
|
||||||
@ -19,6 +18,9 @@ import { GeneralConfigScreenComponent } from './screens/general-config/general-c
|
|||||||
import { BaseAdminScreenComponent } from './base-admin-screen/base-admin-screen.component';
|
import { BaseAdminScreenComponent } from './base-admin-screen/base-admin-screen.component';
|
||||||
import { BaseDossierTemplateScreenComponent } from './base-dossier-templates-screen/base-dossier-template-screen.component';
|
import { BaseDossierTemplateScreenComponent } from './base-dossier-templates-screen/base-dossier-template-screen.component';
|
||||||
import { DossierTemplatesGuard } from '../../guards/dossier-templates.guard';
|
import { DossierTemplatesGuard } from '../../guards/dossier-templates.guard';
|
||||||
|
import { DICTIONARY_TYPE, DOSSIER_TEMPLATE_ID } from '@utils/constants';
|
||||||
|
import { DossierTemplateExistsGuard } from '../../guards/dossier-template-exists.guard';
|
||||||
|
import { DictionaryExistsGuard } from '../../guards/dictionary-exists.guard';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'dossier-templates', pathMatch: 'full' },
|
{ path: '', redirectTo: 'dossier-templates', pathMatch: 'full' },
|
||||||
@ -30,7 +32,7 @@ const routes: Routes = [
|
|||||||
component: BaseAdminScreenComponent,
|
component: BaseAdminScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import('./screens/dossier-templates-listing/dossier-templates-listing.module').then(
|
import('./screens/dossier-templates-listing/dossier-templates-listing.module').then(
|
||||||
@ -38,7 +40,7 @@ const routes: Routes = [
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':dossierTemplateId',
|
path: `:${DOSSIER_TEMPLATE_ID}`,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'info',
|
path: 'info',
|
||||||
@ -54,16 +56,16 @@ const routes: Routes = [
|
|||||||
component: DictionaryListingScreenComponent,
|
component: DictionaryListingScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':dictionary',
|
path: `:${DICTIONARY_TYPE}`,
|
||||||
component: DictionaryOverviewScreenComponent,
|
component: DictionaryOverviewScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
canDeactivate: [PendingChangesGuard],
|
canDeactivate: [PendingChangesGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard, DictionaryExistsGuard],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -74,7 +76,7 @@ const routes: Routes = [
|
|||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
canDeactivate: [PendingChangesGuard],
|
canDeactivate: [PendingChangesGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
loadChildren: () => import('./screens/rules/rules.module').then(m => m.RulesModule),
|
loadChildren: () => import('./screens/rules/rules.module').then(m => m.RulesModule),
|
||||||
},
|
},
|
||||||
@ -83,7 +85,7 @@ const routes: Routes = [
|
|||||||
component: FileAttributesListingScreenComponent,
|
component: FileAttributesListingScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -91,7 +93,7 @@ const routes: Routes = [
|
|||||||
component: BaseDossierTemplateScreenComponent,
|
component: BaseDossierTemplateScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
loadChildren: () => import('./screens/watermark/watermark.module').then(m => m.WatermarkModule),
|
loadChildren: () => import('./screens/watermark/watermark.module').then(m => m.WatermarkModule),
|
||||||
},
|
},
|
||||||
@ -100,7 +102,7 @@ const routes: Routes = [
|
|||||||
component: BaseDossierTemplateScreenComponent,
|
component: BaseDossierTemplateScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
loadChildren: () => import('./screens/reports/reports.module').then(m => m.ReportsModule),
|
loadChildren: () => import('./screens/reports/reports.module').then(m => m.ReportsModule),
|
||||||
},
|
},
|
||||||
@ -109,7 +111,7 @@ const routes: Routes = [
|
|||||||
component: DossierAttributesListingScreenComponent,
|
component: DossierAttributesListingScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -117,7 +119,7 @@ const routes: Routes = [
|
|||||||
component: DefaultColorsScreenComponent,
|
component: DefaultColorsScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -128,11 +130,13 @@ const routes: Routes = [
|
|||||||
},
|
},
|
||||||
{ path: '', redirectTo: 'info', pathMatch: 'full' },
|
{ path: '', redirectTo: 'info', pathMatch: 'full' },
|
||||||
],
|
],
|
||||||
|
canActivate: [CompositeRouteGuard],
|
||||||
|
data: { routeGuards: [DossierTemplateExistsGuard] },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, DossierTemplatesGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard, DossierTemplatesGuard],
|
||||||
requiredRoles: ['RED_MANAGER', 'RED_ADMIN'],
|
requiredRoles: ['RED_MANAGER', 'RED_ADMIN'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -141,7 +145,7 @@ const routes: Routes = [
|
|||||||
component: UserListingScreenComponent,
|
component: UserListingScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_USER_ADMIN'],
|
requiredRoles: ['RED_USER_ADMIN'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -150,7 +154,7 @@ const routes: Routes = [
|
|||||||
component: LicenseInformationScreenComponent,
|
component: LicenseInformationScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_ADMIN'],
|
requiredRoles: ['RED_ADMIN'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -159,7 +163,7 @@ const routes: Routes = [
|
|||||||
component: DigitalSignatureScreenComponent,
|
component: DigitalSignatureScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_ADMIN'],
|
requiredRoles: ['RED_ADMIN'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -168,7 +172,7 @@ const routes: Routes = [
|
|||||||
component: AuditScreenComponent,
|
component: AuditScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_ADMIN'],
|
requiredRoles: ['RED_ADMIN'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -178,7 +182,7 @@ const routes: Routes = [
|
|||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
canDeactivate: [PendingChangesGuard],
|
canDeactivate: [PendingChangesGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_ADMIN'],
|
requiredRoles: ['RED_ADMIN'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -187,7 +191,7 @@ const routes: Routes = [
|
|||||||
component: TrashScreenComponent,
|
component: TrashScreenComponent,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard],
|
routeGuards: [AuthGuard, RedRoleGuard],
|
||||||
requiredRoles: ['RED_MANAGER'],
|
requiredRoles: ['RED_MANAGER'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { FilePreviewGuard } from '@guards/file-preview.guard';
|
|||||||
import { DossierFilesGuard } from '@guards/dossier-files-guard';
|
import { DossierFilesGuard } from '@guards/dossier-files-guard';
|
||||||
import { CompositeRouteGuard } from '@iqser/common-ui';
|
import { CompositeRouteGuard } from '@iqser/common-ui';
|
||||||
import { BreadcrumbTypes } from '@red/domain';
|
import { BreadcrumbTypes } from '@red/domain';
|
||||||
|
import { DOSSIER_ID, FILE_ID } from '@utils/constants';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@ -12,7 +13,7 @@ const routes: Routes = [
|
|||||||
component: SearchScreenComponent,
|
component: SearchScreenComponent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':dossierId',
|
path: `:${DOSSIER_ID}`,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [DossierFilesGuard],
|
routeGuards: [DossierFilesGuard],
|
||||||
@ -21,7 +22,7 @@ const routes: Routes = [
|
|||||||
loadChildren: () => import('./screens/dossier-overview/dossier-overview.module').then(m => m.DossierOverviewModule),
|
loadChildren: () => import('./screens/dossier-overview/dossier-overview.module').then(m => m.DossierOverviewModule),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':dossierId/file/:fileId',
|
path: `:${DOSSIER_ID}/file/:${FILE_ID}`,
|
||||||
canActivate: [CompositeRouteGuard],
|
canActivate: [CompositeRouteGuard],
|
||||||
data: {
|
data: {
|
||||||
routeGuards: [DossierFilesGuard, FilePreviewGuard],
|
routeGuards: [DossierFilesGuard, FilePreviewGuard],
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import jwt_decode from 'jwt-decode';
|
|||||||
import { ICreateUserRequest, IMyProfileUpdateRequest, IProfileUpdateRequest, IResetPasswordRequest, IUser, User } from '@red/domain';
|
import { ICreateUserRequest, IMyProfileUpdateRequest, IProfileUpdateRequest, IResetPasswordRequest, IUser, User } from '@red/domain';
|
||||||
import { wipeCaches } from '@redaction/red-cache';
|
import { wipeCaches } from '@redaction/red-cache';
|
||||||
import { BASE_HREF } from '../tokens';
|
import { BASE_HREF } from '../tokens';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, firstValueFrom, Observable } from 'rxjs';
|
||||||
import { EntitiesService, List, mapEach, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
import { EntitiesService, List, mapEach, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -36,6 +36,12 @@ export class UserService extends EntitiesService<User, IUser> {
|
|||||||
return this.all.filter(user => user.isUser || user.isManager);
|
return this.all.filter(user => user.isUser || user.isManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async initialize(): Promise<void> {
|
||||||
|
if (this.currentUser.isUserAdmin || this.currentUser.isUser || this.currentUser.isAdmin) {
|
||||||
|
await firstValueFrom(this.loadAll());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
wipeCaches().then();
|
wipeCaches().then();
|
||||||
this._keycloakService.logout(window.location.origin + this._baseHref).then();
|
this._keycloakService.logout(window.location.origin + this._baseHref).then();
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
|
|
||||||
import { UserService } from '@services/user.service';
|
|
||||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
|
||||||
import { firstValueFrom } from 'rxjs';
|
|
||||||
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
|
|
||||||
import { DictionaryService } from '@shared/services/dictionary.service';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class AppStateGuard implements CanActivate {
|
|
||||||
constructor(
|
|
||||||
private readonly _dictionaryService: DictionaryService,
|
|
||||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
|
||||||
private readonly _dictionariesMapService: DictionariesMapService,
|
|
||||||
private readonly _userService: UserService,
|
|
||||||
private readonly _router: Router,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async canActivate(route: ActivatedRouteSnapshot): Promise<boolean> {
|
|
||||||
if (this._userService.currentUser.isUserAdmin) {
|
|
||||||
await firstValueFrom(this._userService.loadAll());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._userService.currentUser.isUser || this._userService.currentUser.isAdmin) {
|
|
||||||
await firstValueFrom(this._userService.loadAll());
|
|
||||||
}
|
|
||||||
|
|
||||||
const { dossierTemplateId, type } = route.params;
|
|
||||||
|
|
||||||
if (dossierTemplateId && !this._dossierTemplatesService.find(dossierTemplateId as string)) {
|
|
||||||
await this._router.navigate(['main', 'admin', 'dossier-templates']);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type && !this._dictionariesMapService.get(dossierTemplateId, type)) {
|
|
||||||
await this._router.navigate(['main', 'admin', 'dossier-templates', dossierTemplateId]);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -27,7 +27,6 @@
|
|||||||
"@redaction/red-cache": ["libs/red-cache/src/index.ts"],
|
"@redaction/red-cache": ["libs/red-cache/src/index.ts"],
|
||||||
"@services/*": ["apps/red-ui/src/app/services/*"],
|
"@services/*": ["apps/red-ui/src/app/services/*"],
|
||||||
"@shared/*": ["apps/red-ui/src/app/modules/shared/*"],
|
"@shared/*": ["apps/red-ui/src/app/modules/shared/*"],
|
||||||
"@state/*": ["apps/red-ui/src/app/state/*"],
|
|
||||||
"@upload-download/*": ["apps/red-ui/src/app/modules/upload-download/*"],
|
"@upload-download/*": ["apps/red-ui/src/app/modules/upload-download/*"],
|
||||||
"@utils/*": ["apps/red-ui/src/app/utils/*"]
|
"@utils/*": ["apps/red-ui/src/app/utils/*"]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user