Fixed password settings so that changed passwords actually work and I can actually change the passwords
This commit is contained in:
@@ -92,6 +92,23 @@ class ApiService {
|
||||
return data;
|
||||
}
|
||||
|
||||
async changePassword(id, oldPassword, newPassword) {
|
||||
const response = await fetch(`${this.baseUrl}/users/${id}/password`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
|
||||
},
|
||||
body: JSON.stringify({ old_password: oldPassword, new_password: newPassword }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
let detail = response.statusText;
|
||||
try { const j = await response.json(); if (j.detail) detail = j.detail; } catch {}
|
||||
throw new Error(detail);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async getTasks() {
|
||||
return this.request('/tasks');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user