Replaced one-pager with multiple pages and fixed security bugs
This commit is contained in:
+8
-2
@@ -22,13 +22,14 @@ async function api(method, path, body) {
|
||||
}
|
||||
|
||||
const API = {
|
||||
login: (u, p) => api("POST", "/api/login", { username: u, password: p }),
|
||||
login: (u, p) => api("POST", "/api/login", { username: String(u || "").toLowerCase().trim(), password: p }),
|
||||
logout: () => api("POST", "/api/logout"),
|
||||
me: () => api("GET", "/api/me"),
|
||||
updateMe: (b) => api("PATCH", "/api/me", b),
|
||||
|
||||
listUsers: () => api("GET", "/api/users"),
|
||||
createUser: (b) => api("POST", "/api/users", b),
|
||||
updateUser: (id, b) => api("PATCH", `/api/users/${id}`, b),
|
||||
deleteUser: (id) => api("DELETE", `/api/users/${id}`),
|
||||
|
||||
listCompetitions: () => api("GET", "/api/competitions"),
|
||||
@@ -60,7 +61,12 @@ const API = {
|
||||
createPenalty: (id, b) => api("POST", `/api/competitions/${id}/penalties`, b),
|
||||
updatePenalty: (id, pid, b) => api("PATCH", `/api/competitions/${id}/penalties/${pid}`, b),
|
||||
deletePenalty: (id, pid) => api("DELETE", `/api/competitions/${id}/penalties/${pid}`),
|
||||
exportPenaltiesURL: (id) => apiURL(`/api/competitions/${id}/penalties.csv`),
|
||||
applyPenalties: (id, b) => api("POST", `/api/competitions/${id}/penalties/apply`, b),
|
||||
exportPenaltiesCSV: async (id) => {
|
||||
const res = await fetch(apiURL(`/api/competitions/${id}/penalties.csv`), { credentials: "include" });
|
||||
if (!res.ok) throw new Error("export_failed");
|
||||
return res.blob();
|
||||
},
|
||||
|
||||
listRules: (lang) => api("GET", `/api/rules${lang ? "?lang=" + encodeURIComponent(lang) : ""}`),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user