implemented role and state based authorization

This commit is contained in:
2025-12-13 17:01:50 -05:00
parent 7c4e8d7db8
commit b91ecacb60
8 changed files with 101 additions and 60 deletions

View File

@@ -59,7 +59,9 @@ export async function postAdminChatMessage(message: any, post_id: number) {
}
export async function getAllApplications(): Promise<ApplicationFull> {
const res = await fetch(`${addr}/application/all`)
const res = await fetch(`${addr}/application/all`, {
credentials: 'include',
})
if (res.ok) {
return res.json()

View File

@@ -4,7 +4,9 @@ import { Course, CourseAttendeeRole, CourseEventDetails, CourseEventSummary } fr
const addr = import.meta.env.VITE_APIHOST;
export async function getTrainingReports(sortMode: string, search: string): Promise<CourseEventSummary[]> {
const res = await fetch(`${addr}/courseEvent?sort=${sortMode}&search=${search}`);
const res = await fetch(`${addr}/courseEvent?sort=${sortMode}&search=${search}`, {
credentials: 'include',
});
if (res.ok) {
return await res.json() as Promise<CourseEventSummary[]>;
@@ -15,7 +17,9 @@ export async function getTrainingReports(sortMode: string, search: string): Prom
}
export async function getTrainingReport(id: number): Promise<CourseEventDetails> {
const res = await fetch(`${addr}/courseEvent/${id}`);
const res = await fetch(`${addr}/courseEvent/${id}`, {
credentials: 'include',
});
if (res.ok) {
return await res.json() as Promise<CourseEventDetails>;
@@ -26,10 +30,12 @@ export async function getTrainingReport(id: number): Promise<CourseEventDetails>
}
export async function getAllTrainings(): Promise<Course[]> {
const res = await fetch(`${addr}/course`);
const res = await fetch(`${addr}/course`, {
credentials: 'include',
});
if (res.ok) {
return await res.json() as Promise<Course[]>;
return await res.json() as Promise<Course[]>;
} else {
console.error("Something went wrong");
throw new Error("Failed to load training list");
@@ -37,7 +43,9 @@ export async function getAllTrainings(): Promise<Course[]> {
}
export async function getAllAttendeeRoles(): Promise<CourseAttendeeRole[]> {
const res = await fetch(`${addr}/course/roles`);
const res = await fetch(`${addr}/course/roles`, {
credentials: 'include',
});
if (res.ok) {
return await res.json() as Promise<CourseAttendeeRole[]>;