Archived
Добавлено удаление инстансов и защита API-клиента
This commit is contained in:
+3
-11
@@ -20,23 +20,14 @@ async function request(path, options = {}) {
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function register(email, password) {
|
||||
return request("/auth/register", { method: "POST", body: JSON.stringify({ email, password }) });
|
||||
}
|
||||
|
||||
export async function register(email, password) { return request("/auth/register", { method: "POST", body: JSON.stringify({ email, password }) }); }
|
||||
export async function login(email, password) {
|
||||
const body = new URLSearchParams({ username: email, password });
|
||||
const response = await fetch(`${BASE}/auth/login`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body,
|
||||
});
|
||||
const response = await fetch(`${BASE}/auth/login`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ username: email, password }) });
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(data.detail || "Ошибка входа");
|
||||
setToken(data.access_token);
|
||||
return data;
|
||||
}
|
||||
|
||||
export function getMe() { return request("/auth/me"); }
|
||||
export function listTemplates() { return request("/templates"); }
|
||||
export function listProxmoxTemplates() { return request("/templates/from-proxmox"); }
|
||||
@@ -44,3 +35,4 @@ export function createTemplate(payload) { return request("/templates", { method:
|
||||
export function deactivateTemplate(id) { return request(`/templates/${id}`, { method: "DELETE" }); }
|
||||
export function listInstances() { return request("/instances"); }
|
||||
export function createInstance(payload) { return request("/instances", { method: "POST", body: JSON.stringify(payload) }); }
|
||||
export function deleteInstance(id) { return request(`/instances/${id}`, { method: "DELETE" }); }
|
||||
|
||||
Reference in New Issue
Block a user