csrf token handling, two jwt tokens

This commit is contained in:
jackiettran
2025-11-26 14:25:49 -05:00
parent f3a356d64b
commit 8b10103ae4
8 changed files with 114 additions and 76 deletions

View File

@@ -39,7 +39,7 @@ const api = axios.create({
export const fetchCSRFToken = async (): Promise<string> => {
try {
const response = await api.get("/auth/csrf-token");
csrfToken = response.data.csrfToken || "";
csrfToken = response.headers["x-csrf-token"] || "";
return csrfToken || "";
} catch (error) {
console.error("Failed to fetch CSRF token:", error);
@@ -286,10 +286,14 @@ export const forumAPI = {
deleteComment: (commentId: string) =>
api.delete(`/forum/comments/${commentId}`),
// Admin endpoints
adminDeletePost: (id: string, reason: string) => api.delete(`/forum/admin/posts/${id}`, { data: { reason } }),
adminRestorePost: (id: string) => api.patch(`/forum/admin/posts/${id}/restore`),
adminDeleteComment: (id: string, reason: string) => api.delete(`/forum/admin/comments/${id}`, { data: { reason } }),
adminRestoreComment: (id: string) => api.patch(`/forum/admin/comments/${id}/restore`),
adminDeletePost: (id: string, reason: string) =>
api.delete(`/forum/admin/posts/${id}`, { data: { reason } }),
adminRestorePost: (id: string) =>
api.patch(`/forum/admin/posts/${id}/restore`),
adminDeleteComment: (id: string, reason: string) =>
api.delete(`/forum/admin/comments/${id}`, { data: { reason } }),
adminRestoreComment: (id: string) =>
api.patch(`/forum/admin/comments/${id}/restore`),
adminClosePost: (id: string) => api.patch(`/forum/admin/posts/${id}/close`),
adminReopenPost: (id: string) => api.patch(`/forum/admin/posts/${id}/reopen`),
};