(username, password, role)
| 201 | } |
| 202 | |
| 203 | export async function addUser(username, password, role) { |
| 204 | return fetch("/api/user", { |
| 205 | method: "POST", |
| 206 | headers: { |
| 207 | "X-CSRFToken": getCsrfToken(), |
| 208 | "Content-Type": "application/json", |
| 209 | }, |
| 210 | credentials: "same-origin", |
| 211 | mode: "same-origin", |
| 212 | cache: "no-cache", |
| 213 | redirect: "error", |
| 214 | body: JSON.stringify({ username, password, role }), |
| 215 | }) |
| 216 | .then(processJsonResponse) |
| 217 | .then((data) => { |
| 218 | if (!Object.hasOwn(data, "username")) { |
| 219 | throw new ControllerError("Missing expected username field"); |
| 220 | } |
| 221 | return { username: data.username }; |
| 222 | }); |
| 223 | } |
| 224 | |
| 225 | export async function updateUserPassword(username, password) { |
| 226 | return fetch("/api/user/password", { |
nothing calls this directly
no test coverage detected