Do not override `withCredentials` params when set

pull/7878/head
Henriette Dinger 5 years ago committed by Oliver Günther
parent 1aa644ebd8
commit f921d3698f
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 5
      frontend/src/app/components/work-packages/work-package.service.ts
  2. 3
      frontend/src/app/modules/hal/dm-services/query-order-dm.service.ts
  3. 31
      frontend/src/app/modules/hal/http/openproject-header-interceptor.ts

@ -56,7 +56,10 @@ export class WorkPackageService {
'ids[]': ids
};
const promise = this.http
.delete(this.PathHelper.workPackagesBulkDeletePath(), {params: params})
.delete(
this.PathHelper.workPackagesBulkDeletePath(),
{params: params, withCredentials: true}
)
.toPromise();
if (defaultHandling) {

@ -51,7 +51,8 @@ export class QueryOrderDmService {
return this.http
.patch(
this.orderPath(id),
{ delta: delta }
{ delta: delta },
{ withCredentials: true }
)
.toPromise()
.then((response:{t:string}) => response.t);

@ -10,21 +10,26 @@ export class OpenProjectHeaderInterceptor implements HttpInterceptor {
intercept(req:HttpRequest<any>, next:HttpHandler):Observable<HttpEvent<any>> {
const csrf_token:string|undefined = jQuery('meta[name=csrf-token]').attr('content');
let newHeaders = req.headers
.set('X-Authentication-Scheme', 'Session')
.set('X-Requested-With', 'XMLHttpRequest');
if (req.withCredentials !== false) {
if (csrf_token) {
newHeaders = newHeaders.set('X-CSRF-TOKEN', csrf_token);
}
let newHeaders = req.headers
.set('X-Authentication-Scheme', 'Session')
.set('X-Requested-With', 'XMLHttpRequest');
if (csrf_token) {
newHeaders = newHeaders.set('X-CSRF-TOKEN', csrf_token);
}
// Clone the request to add the new header
const clonedRequest = req.clone({
withCredentials: true,
headers: newHeaders
});
// Clone the request to add the new header
const clonedRequest = req.clone({
withCredentials: true,
headers: newHeaders
});
// Pass the cloned request instead of the original request to the next handle
return next.handle(clonedRequest);
}
// Pass the cloned request instead of the original request to the next handle
return next.handle(clonedRequest);
return next.handle(req);
}
}

Loading…
Cancel
Save