forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
114858: Create and Add Guards to item&bitstream routes
- Loading branch information
Zahraa Chreim
committed
May 8, 2024
1 parent
08028dc
commit 4658ac8
Showing
7 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/app/bitstream-page/bitstream-page-authorizations.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { inject } from '@angular/core'; | ||
import { CanActivateFn, ResolveFn } from '@angular/router'; | ||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { BitstreamPageResolver } from './bitstream-page.resolver'; | ||
import { Bitstream } from '../core/shared/bitstream.model'; | ||
import { dsoPageSingleFeatureGuard } from '../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard'; | ||
import { FeatureID } from '../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../core/data/remote-data'; | ||
|
||
/** | ||
* Guard for preventing unauthorized access to certain {@link Bitstream} pages requiring specific authorizations. | ||
* Checks authorization rights for managing policies. | ||
*/ | ||
export const bitstreamPageAuthorizationsGuard: CanActivateFn = | ||
dsoPageSingleFeatureGuard( | ||
() => { | ||
const bitstreamPageResolver = inject(BitstreamPageResolver); | ||
return bitstreamPageResolver.resolve as ResolveFn<Observable<RemoteData<Bitstream>>>; | ||
}, | ||
() => observableOf(FeatureID.CanManagePolicies) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/app/item-page/edit-item-page/item-page-delete.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { inject } from '@angular/core'; | ||
import { | ||
dsoPageSingleFeatureGuard | ||
} from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard'; | ||
import { Item } from '../../core/shared/item.model'; | ||
import { ItemPageResolver } from '../item-page.resolver'; | ||
import { CanActivateFn, ResolveFn } from '@angular/router'; | ||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { FeatureID } from '../../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
|
||
/** | ||
* Guard for preventing unauthorized access to certain {@link Item} pages requiring specific authorizations. | ||
* Checks authorization rights for deleting items. | ||
*/ | ||
export const itemPageDeleteGuard: CanActivateFn = | ||
dsoPageSingleFeatureGuard( | ||
() => { | ||
const itemPageResolver = inject(ItemPageResolver); | ||
return itemPageResolver.resolve as ResolveFn<Observable<RemoteData<Item>>>; | ||
}, | ||
() => observableOf(FeatureID.CanDelete) | ||
); |
23 changes: 23 additions & 0 deletions
23
src/app/item-page/edit-item-page/item-page-edit-authorizations.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { inject } from '@angular/core'; | ||
import { | ||
dsoPageSingleFeatureGuard | ||
} from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard'; | ||
import { Item } from '../../core/shared/item.model'; | ||
import { ItemPageResolver } from '../item-page.resolver'; | ||
import { CanActivateFn, ResolveFn } from '@angular/router'; | ||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { FeatureID } from '../../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
|
||
/** | ||
* Guard for preventing unauthorized access to certain {@link Item} pages requiring specific authorizations. | ||
* Checks authorization rights for managing policies. | ||
*/ | ||
export const itemPageEditAuthorizationsGuard: CanActivateFn = | ||
dsoPageSingleFeatureGuard( | ||
() => { | ||
const itemPageResolver = inject(ItemPageResolver); | ||
return itemPageResolver.resolve as ResolveFn<Observable<RemoteData<Item>>>; | ||
}, | ||
() => observableOf(FeatureID.CanManagePolicies) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { inject } from '@angular/core'; | ||
import { | ||
dsoPageSingleFeatureGuard | ||
} from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard'; | ||
import { Item } from '../../core/shared/item.model'; | ||
import { ItemPageResolver } from '../item-page.resolver'; | ||
import { CanActivateFn, ResolveFn } from '@angular/router'; | ||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { FeatureID } from '../../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
|
||
/** | ||
* Guard for preventing unauthorized access to certain {@link Item} pages requiring specific authorizations. | ||
* Checks authorization rights for moving items. | ||
*/ | ||
export const itemPageMoveGuard: CanActivateFn = | ||
dsoPageSingleFeatureGuard( | ||
() => { | ||
const itemPageResolver = inject(ItemPageResolver); | ||
return itemPageResolver.resolve as ResolveFn<Observable<RemoteData<Item>>>; | ||
}, | ||
() => observableOf(FeatureID.CanMove) | ||
); |
23 changes: 23 additions & 0 deletions
23
src/app/item-page/edit-item-page/item-page-private.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { inject } from '@angular/core'; | ||
import { | ||
dsoPageSingleFeatureGuard | ||
} from '../../core/data/feature-authorization/feature-authorization-guard/dso-page-single-feature.guard'; | ||
import { Item } from '../../core/shared/item.model'; | ||
import { ItemPageResolver } from '../item-page.resolver'; | ||
import { CanActivateFn, ResolveFn } from '@angular/router'; | ||
import { Observable, of as observableOf } from 'rxjs'; | ||
import { FeatureID } from '../../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../../core/data/remote-data'; | ||
|
||
/** | ||
* Guard for preventing unauthorized access to certain {@link Item} pages requiring specific authorizations. | ||
* Checks authorization rights for making items private. | ||
*/ | ||
export const itemPagePrivateGuard: CanActivateFn = | ||
dsoPageSingleFeatureGuard( | ||
() => { | ||
const itemPageResolver = inject(ItemPageResolver); | ||
return itemPageResolver.resolve as ResolveFn<Observable<RemoteData<Item>>>; | ||
}, | ||
() => observableOf(FeatureID.CanMakePrivate) | ||
); |