1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/utils/csrf.js
2016-06-14 17:58:00 +02:00

15 lines
354 B
JavaScript

import { getCookie } from './cookie.js';
import { CSRF_COOKIE_NAME, CSRF_CUSTOM_HEADER_NAME } from '../constants/csrf_constants';
export function getCsrfToken() {
return getCookie(CSRF_COOKIE_NAME);
}
export function makeCsrfHeader(csrfToken = getCsrfToken()) {
return csrfToken ? {
[CSRF_CUSTOM_HEADER_NAME]: csrfToken
} : {};
}