[develop | DONE | ADDED] create CommunityAccess guard, replace isCommunity guard
This commit is contained in:
parent
9d54e942b7
commit
73b9a03d60
|
@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
|
||||||
import {RouterModule, Routes} from '@angular/router';
|
import {RouterModule, Routes} from '@angular/router';
|
||||||
import {OpenaireErrorPageComponent} from './error/errorPage.component';
|
import {OpenaireErrorPageComponent} from './error/errorPage.component';
|
||||||
import {PageURLResolverComponent} from "./openaireLibrary/utils/pageURLResolver.component";
|
import {PageURLResolverComponent} from "./openaireLibrary/utils/pageURLResolver.component";
|
||||||
import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard";
|
import {CommunityAccessGuard} from "./utils/communityAccess.guard";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
// ORCID Pages
|
// ORCID Pages
|
||||||
|
@ -40,7 +40,7 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'content',
|
path: 'content',
|
||||||
loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule),
|
loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'sdgs',
|
path: 'sdgs',
|
||||||
|
@ -55,22 +55,22 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'organizations',
|
path: 'organizations',
|
||||||
loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule),
|
loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'publications',
|
path: 'publications',
|
||||||
loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule),
|
loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'projects',
|
path: 'projects',
|
||||||
loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule),
|
loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'national-bulletins',
|
path: 'national-bulletins',
|
||||||
loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule),
|
loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'faqs',
|
path: 'faqs',
|
||||||
|
@ -88,24 +88,24 @@ const routes: Routes = [
|
||||||
// {
|
// {
|
||||||
// path: '',
|
// path: '',
|
||||||
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
|
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
|
||||||
// data: {hasQuickContact: false}, canActivateChild: [IsCommunity],
|
// data: {hasQuickContact: false}, canActivateChild: [CommunityAccessGuard],
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// path: '**',
|
// path: '**',
|
||||||
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
|
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
|
||||||
// data: {hasQuickContact: false}, canActivateChild: [IsCommunity],
|
// data: {hasQuickContact: false}, canActivateChild: [CommunityAccessGuard],
|
||||||
// },
|
// },
|
||||||
// ]
|
// ]
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: 'curators',
|
path: 'curators',
|
||||||
loadChildren: () => import('./curators/curators.module').then(m => m.CuratorsModule),
|
loadChildren: () => import('./curators/curators.module').then(m => m.CuratorsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'subjects',
|
path: 'subjects',
|
||||||
loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule),
|
loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'myCommunities',
|
path: 'myCommunities',
|
||||||
|
@ -114,7 +114,7 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'develop',
|
path: 'develop',
|
||||||
loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule),
|
loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
/** Testing Page for help contents */
|
/** Testing Page for help contents */
|
||||||
{path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)},
|
{path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)},
|
||||||
|
@ -122,41 +122,41 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'search/result',
|
path: 'search/result',
|
||||||
loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule),
|
loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/publication',
|
path: 'search/publication',
|
||||||
loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule),
|
loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/dataset',
|
path: 'search/dataset',
|
||||||
loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule),
|
loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/software',
|
path: 'search/software',
|
||||||
loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule),
|
loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule),
|
path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/project',
|
path: 'search/project',
|
||||||
loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule),
|
loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/dataprovider',
|
path: 'search/dataprovider',
|
||||||
loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule),
|
loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/organization',
|
path: 'search/organization',
|
||||||
loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule),
|
loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule),
|
||||||
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
/** Search Pages */
|
/** Search Pages */
|
||||||
{path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'},
|
{path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'},
|
||||||
|
@ -168,86 +168,86 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'search/find/research-outcomes',
|
path: 'search/find/research-outcomes',
|
||||||
loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule),
|
loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/find/publications',
|
path: 'search/find/publications',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/find/datasets',
|
path: 'search/find/datasets',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/find/software',
|
path: 'search/find/software',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/find/other',
|
path: 'search/find/other',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/find/projects',
|
path: 'search/find/projects',
|
||||||
loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule),
|
loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/find/dataproviders',
|
path: 'search/find/dataproviders',
|
||||||
loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule),
|
loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
/** Advanced Search Pages */
|
/** Advanced Search Pages */
|
||||||
{
|
{
|
||||||
path: 'search/advanced/research-outcomes',
|
path: 'search/advanced/research-outcomes',
|
||||||
loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule),
|
loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/publications',
|
path: 'search/advanced/publications',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/datasets',
|
path: 'search/advanced/datasets',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/software',
|
path: 'search/advanced/software',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/other',
|
path: 'search/advanced/other',
|
||||||
component: PageURLResolverComponent,
|
component: PageURLResolverComponent,
|
||||||
data: {hasQuickContact: false},
|
data: {hasQuickContact: false},
|
||||||
canActivate: [IsCommunity]
|
canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/organizations',
|
path: 'search/advanced/organizations',
|
||||||
loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule),
|
loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/dataproviders',
|
path: 'search/advanced/dataproviders',
|
||||||
loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule),
|
loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'search/advanced/projects',
|
path: 'search/advanced/projects',
|
||||||
loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule),
|
loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
/** Deposit Pages */
|
/** Deposit Pages */
|
||||||
{ path: 'participate/deposit-datasets',
|
{ path: 'participate/deposit-datasets',
|
||||||
|
@ -271,37 +271,37 @@ const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'participate/deposit/learn-how',
|
path: 'participate/deposit/learn-how',
|
||||||
loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule),
|
loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'participate/deposit/search',
|
path: 'participate/deposit/search',
|
||||||
loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule),
|
loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'participate/deposit/zenodo',
|
path: 'participate/deposit/zenodo',
|
||||||
loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule),
|
loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
/** Linking Pages */
|
/** Linking Pages */
|
||||||
{
|
{
|
||||||
path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule),
|
path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'participate/claim',
|
path: 'participate/claim',
|
||||||
loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule),
|
loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'participate/direct-claim',
|
path: 'participate/direct-claim',
|
||||||
loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule),
|
loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'preview',
|
path: 'preview',
|
||||||
loadChildren: () => import('./demo/demo.module').then(m => m.DemoModule),
|
loadChildren: () => import('./demo/demo.module').then(m => m.DemoModule),
|
||||||
data: {hasQuickContact: false}, canActivate: [IsCommunity]
|
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
|
||||||
},
|
},
|
||||||
/** help pages - do not exist in Admin portal/api/db */
|
/** help pages - do not exist in Admin portal/api/db */
|
||||||
{
|
{
|
||||||
|
|
|
@ -308,11 +308,13 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
initAdminToolCommunity(communityId) {
|
initAdminToolCommunity(communityId) {
|
||||||
if (communityId) {
|
if (communityId) {
|
||||||
this.properties.adminToolsPortalType = "community";
|
this.properties.adminToolsPortalType = "community";
|
||||||
|
this.properties.adminToolsCommunity = communityId;
|
||||||
if (this.document) {
|
if (this.document) {
|
||||||
this.initLayout(communityId);
|
this.initLayout(communityId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.properties.adminToolsPortalType = "connect";
|
this.properties.adminToolsPortalType = "connect";
|
||||||
|
this.properties.adminToolsCommunity = "connect";
|
||||||
if (this.document) {
|
if (this.document) {
|
||||||
this.initLayout(this.communityId?this.communityId:'connect');
|
this.initLayout(this.communityId?this.communityId:'connect');
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,12 @@ import {PageURLResolverModule} from "./openaireLibrary/utils/pageURLResolver.mod
|
||||||
import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
|
import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
|
||||||
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
|
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
|
||||||
import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service";
|
import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service";
|
||||||
import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard";
|
|
||||||
import {SubscribeService} from "./openaireLibrary/utils/subscribe/subscribe.service";
|
import {SubscribeService} from "./openaireLibrary/utils/subscribe/subscribe.service";
|
||||||
import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module";
|
import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module";
|
||||||
import {QuickContactModule} from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.module";
|
import {QuickContactModule} from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.module";
|
||||||
import {AlertModalModule} from "./openaireLibrary/utils/modal/alertModal.module";
|
import {AlertModalModule} from "./openaireLibrary/utils/modal/alertModal.module";
|
||||||
import {CustomizationService} from "./openaireLibrary/services/customization.service";
|
import {CustomizationService} from "./openaireLibrary/services/customization.service";
|
||||||
|
import {CommunityAccessGuard} from "./utils/communityAccess.guard";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ import {CustomizationService} from "./openaireLibrary/services/customization.ser
|
||||||
declarations: [AppComponent, OpenaireErrorPageComponent],
|
declarations: [AppComponent, OpenaireErrorPageComponent],
|
||||||
exports: [AppComponent],
|
exports: [AppComponent],
|
||||||
providers: [
|
providers: [
|
||||||
CommunitiesService, CustomizationService, IsCommunity, SubscribeService,
|
CommunitiesService, CustomizationService, CommunityAccessGuard, SubscribeService,
|
||||||
{provide: APP_ID, useValue: 'serverApp'},
|
{provide: APP_ID, useValue: 'serverApp'},
|
||||||
{
|
{
|
||||||
provide: HTTP_INTERCEPTORS,
|
provide: HTTP_INTERCEPTORS,
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||||
|
import {forkJoin, Observable} from 'rxjs';
|
||||||
|
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
|
||||||
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||||
|
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
||||||
|
import {properties} from "../../environments/environment";
|
||||||
|
import {map, take} from "rxjs/operators";
|
||||||
|
import {LoginErrorCodes} from "../openaireLibrary/login/utils/guardHelper.class";
|
||||||
|
import {Session} from "../openaireLibrary/login/utils/helper.class";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CommunityAccessGuard {
|
||||||
|
|
||||||
|
constructor(private router: Router,
|
||||||
|
private communityService: CommunityService, private userManagementService: UserManagementService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
check(path: string): Observable<boolean> | boolean {
|
||||||
|
let community = ConnectHelper.getCommunityFromDomain(properties.domain);
|
||||||
|
if (!community) {
|
||||||
|
this.router.navigate([properties.errorLink], {queryParams: {page: path}});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return forkJoin([
|
||||||
|
this.userManagementService.getUserInfo().pipe(take(1)),
|
||||||
|
this.communityService.getCommunity(community).pipe(take(1))
|
||||||
|
]).pipe(
|
||||||
|
map(([user, communityInfo]) => {
|
||||||
|
console.log(user, communityInfo)
|
||||||
|
if (communityInfo) {
|
||||||
|
console.log(communityInfo.status)
|
||||||
|
if (communityInfo.isPublic()) {
|
||||||
|
return true;
|
||||||
|
} else if (communityInfo.isPrivate()) {
|
||||||
|
this.router.navigate([properties.errorLink], {queryParams: {page: path}});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (!user) {
|
||||||
|
this.router.navigate(['/user-info'], {
|
||||||
|
queryParams: {
|
||||||
|
'errorCode': LoginErrorCodes.NOT_LOGIN,
|
||||||
|
'redirectUrl': path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user) || Session.isSubscribedTo('community', community, user)) {
|
||||||
|
console.log("user: has access")
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
this.router.navigate(['/user-info'], {
|
||||||
|
queryParams: {
|
||||||
|
'errorCode': LoginErrorCodes.NOT_AUTHORIZED,
|
||||||
|
'redirectUrl': path
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.router.navigate([properties.errorLink], {queryParams: {page: path}});
|
||||||
|
return false;
|
||||||
|
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
|
return this.check(state.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
|
return this.check(state.url);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue