mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 16:25:33 +01:00
Merge branch 'dev' into feature-more-like-this
This commit is contained in:
commit
43c88ae0f0
3 changed files with 13 additions and 2 deletions
|
|
@ -7,16 +7,21 @@ import {
|
|||
} from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { CookieService } from 'ngx-cookie-service';
|
||||
import { Meta } from '@angular/platform-browser';
|
||||
|
||||
@Injectable()
|
||||
export class CsrfInterceptor implements HttpInterceptor {
|
||||
|
||||
constructor(private cookieService: CookieService) {
|
||||
constructor(private cookieService: CookieService, private meta: Meta) {
|
||||
|
||||
}
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
let csrfToken = this.cookieService.get('csrftoken')
|
||||
let prefix = ""
|
||||
if (this.meta.getTag('name=cookie_prefix')) {
|
||||
prefix = this.meta.getTag('name=cookie_prefix').content
|
||||
}
|
||||
let csrfToken = this.cookieService.get(`${prefix?prefix:''}csrftoken`)
|
||||
if (csrfToken) {
|
||||
request = request.clone({
|
||||
setHeaders: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue