mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 10:33:01 +00:00
CSRF implementation on server helpers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getAuthHeaders, getServerURL } from "@/lib/utils";
|
||||
import { getServerURL } from "@/lib/utils";
|
||||
import type { ServerQueryInput } from "..";
|
||||
|
||||
export async function byProject({
|
||||
@@ -12,7 +12,7 @@ export async function byProject({
|
||||
url.searchParams.set("projectId", `${projectId}`);
|
||||
|
||||
const res = await fetch(url.toString(), {
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAuthHeaders, getServerURL } from "@/lib/utils";
|
||||
import { getCsrfToken, getServerURL } from "@/lib/utils";
|
||||
import type { ServerQueryInput } from "..";
|
||||
|
||||
export async function create({
|
||||
@@ -20,8 +20,13 @@ export async function create({
|
||||
if (description.trim() !== "") url.searchParams.set("description", description.trim());
|
||||
if (assigneeId != null) url.searchParams.set("assigneeId", `${assigneeId}`);
|
||||
|
||||
const csrfToken = getCsrfToken();
|
||||
const headers: HeadersInit = {};
|
||||
if (csrfToken) headers["X-CSRF-Token"] = csrfToken;
|
||||
|
||||
const res = await fetch(url.toString(), {
|
||||
headers: getAuthHeaders(),
|
||||
headers,
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAuthHeaders, getServerURL } from "@/lib/utils";
|
||||
import { getCsrfToken, getServerURL } from "@/lib/utils";
|
||||
import type { ServerQueryInput } from "..";
|
||||
|
||||
export async function update({
|
||||
@@ -22,8 +22,13 @@ export async function update({
|
||||
url.searchParams.set("assigneeId", assigneeId === null ? "null" : `${assigneeId}`);
|
||||
}
|
||||
|
||||
const csrfToken = getCsrfToken();
|
||||
const headers: HeadersInit = {};
|
||||
if (csrfToken) headers["X-CSRF-Token"] = csrfToken;
|
||||
|
||||
const res = await fetch(url.toString(), {
|
||||
headers: getAuthHeaders(),
|
||||
headers,
|
||||
credentials: "include",
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user