implemented role and state based authorization
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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[]>;
|
||||
|
||||
Reference in New Issue
Block a user