Merge remote-tracking branch 'remotes/origin/master' into submission

# Conflicts:
#	package.json
#	src/app/+admin/admin-registries/metadata-schema/metadata-schema.component.spec.ts
#	src/app/+search-page/search-service/search.service.spec.ts
#	src/app/app.module.ts
#	src/app/core/auth/auth.interceptor.ts
#	src/app/core/cache/response-cache.service.spec.ts
#	src/app/core/data/browse-response-parsing.service.spec.ts
#	src/app/core/data/data.service.spec.ts
#	src/app/core/data/request.service.spec.ts
#	src/app/core/data/request.service.ts
#	src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts
#	src/app/core/integration/integration.service.ts
#	src/app/core/metadata/metadata.service.spec.ts
#	src/app/core/registry/registry.service.spec.ts
#	src/app/core/shared/collection.model.ts
#	src/app/core/shared/item.model.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.component.spec.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.components.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/list/dynamic-list.component.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component.ts
#	src/app/shared/form/builder/form-builder.service.spec.ts
#	src/app/shared/form/form.service.spec.ts
#	src/app/shared/notifications/notification/notification.component.spec.ts
#	src/app/shared/services/route.service.spec.ts
#	src/app/shared/services/route.service.ts
#	src/app/shared/shared.module.ts
#	yarn.lock
This commit is contained in:
Giuseppe Digilio
2018-12-13 20:28:11 +01:00
237 changed files with 6869 additions and 7210 deletions

View File

@@ -1,13 +1,16 @@
import { Observable, of as observableOf, throwError as observableThrowError } from 'rxjs';
import { catchError, filter, map } from 'rxjs/operators';
import { Injectable, Injector } from '@angular/core';
import {
HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse,
HttpErrorResponse, HttpResponseBase
HttpErrorResponse,
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
HttpResponse,
HttpResponseBase
} from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/observable/throw'
import 'rxjs/add/operator/catch';
import { find } from 'lodash';
import { AppState } from '../../app.reducer';
@@ -79,11 +82,11 @@ export class AuthInterceptor implements HttpInterceptor {
// The access token is expired
// Redirect to the login route
this.store.dispatch(new RedirectWhenTokenExpiredAction('auth.messages.expired'));
return Observable.of(null);
return observableOf(null);
} else if (!this.isAuthRequest(req) && isNotEmpty(token)) {
// Intercept a request that is not to the authentication endpoint
authService.isTokenExpiring()
.filter((isExpiring) => isExpiring)
authService.isTokenExpiring().pipe(
filter((isExpiring) => isExpiring))
.subscribe(() => {
// If the current request url is already in the refresh token request list, skip it
if (isUndefined(find(this.refreshTokenRequestUrls, req.url))) {
@@ -101,8 +104,8 @@ export class AuthInterceptor implements HttpInterceptor {
}
// Pass on the new request instead of the original request.
return next.handle(newReq)
.map((response) => {
return next.handle(newReq).pipe(
map((response) => {
// Intercept a Login/Logout response
if (response instanceof HttpResponse && this.isSuccess(response) && (this.isLoginResponse(response) || this.isLogoutResponse(response))) {
// It's a success Login/Logout response
@@ -122,8 +125,8 @@ export class AuthInterceptor implements HttpInterceptor {
} else {
return response;
}
})
.catch((error, caught) => {
}),
catchError((error, caught) => {
// Intercept an error response
if (error instanceof HttpErrorResponse) {
// Checks if is a response from a request to an authentication endpoint
@@ -138,7 +141,7 @@ export class AuthInterceptor implements HttpInterceptor {
statusText: error.statusText,
url: error.url
});
return Observable.of(authResponse);
return observableOf(authResponse);
} else if (this.isUnauthorized(error) && isNotNull(token) && authService.isTokenExpired()) {
// The access token provided is expired, revoked, malformed, or invalid for other reasons
// Redirect to the login route
@@ -146,8 +149,7 @@ export class AuthInterceptor implements HttpInterceptor {
}
}
// Return error response as is.
return Observable.throw(error);
}) as any;
return observableThrowError(error);
})) as any;
}
}