mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-5307] Add useCachedVersionIfAvailable and reRequestOnStale param to isAuthorized method
This commit is contained in:
@@ -65,9 +65,13 @@ export class AuthorizationDataService extends DataService<Authorization> {
|
|||||||
* @param ePersonUuid UUID of the {@link EPerson} to search {@link Authorization}s for.
|
* @param ePersonUuid UUID of the {@link EPerson} to search {@link Authorization}s for.
|
||||||
* If not provided, the UUID of the currently authenticated {@link EPerson} will be used.
|
* If not provided, the UUID of the currently authenticated {@link EPerson} will be used.
|
||||||
* @param featureId ID of the {@link Feature} to check {@link Authorization} for
|
* @param featureId ID of the {@link Feature} to check {@link Authorization} for
|
||||||
|
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
|
||||||
|
* no valid cached version. Defaults to true
|
||||||
|
* @param reRequestOnStale Whether or not the request should automatically be re-
|
||||||
|
* requested after the response becomes stale
|
||||||
*/
|
*/
|
||||||
isAuthorized(featureId?: FeatureID, objectUrl?: string, ePersonUuid?: string): Observable<boolean> {
|
isAuthorized(featureId?: FeatureID, objectUrl?: string, ePersonUuid?: string, useCachedVersionIfAvailable = true, reRequestOnStale = true): Observable<boolean> {
|
||||||
return this.searchByObject(featureId, objectUrl, ePersonUuid, {}, true, true, followLink('feature')).pipe(
|
return this.searchByObject(featureId, objectUrl, ePersonUuid, {}, useCachedVersionIfAvailable, useCachedVersionIfAvailable, followLink('feature')).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
map((authorizationRD) => {
|
map((authorizationRD) => {
|
||||||
if (authorizationRD.statusCode !== 401 && hasValue(authorizationRD.payload) && isNotEmpty(authorizationRD.payload.page)) {
|
if (authorizationRD.statusCode !== 401 && hasValue(authorizationRD.payload) && isNotEmpty(authorizationRD.payload.page)) {
|
||||||
|
Reference in New Issue
Block a user