Implement hashed password transfer, change password, redesign the settings UI

This commit is contained in:
2025-10-30 22:36:23 +03:00
Unverified
parent 1d4a46dff2
commit 5f49b45eed
13 changed files with 381 additions and 74 deletions
+25
View File
@@ -0,0 +1,25 @@
import { API_BASE_URL } from "@/core/config";
import { getAuthHeaders, deriveAuthSecret } from "@/core/api/authApi";
export async function changePassword(
token: string,
username: string,
currentPassword: string,
newPassword: string,
logoutAllExceptCurrent: boolean
): Promise<void> {
const currentDerived = await deriveAuthSecret(username, currentPassword);
const newDerived = await deriveAuthSecret(username, newPassword);
const res = await fetch(`${API_BASE_URL}/change-password`, {
method: "POST",
headers: getAuthHeaders(token),
body: JSON.stringify({
currentPasswordDerived: currentDerived,
newPasswordDerived: newDerived,
logoutAllExceptCurrent
})
});
if (!res.ok) throw new Error("Failed to change password");
}