Fix change-password form to use direct fetch instead of authClient

authClient.changePassword does not exist in better-auth v1.6 client bundle.
Use direct POST to /api/auth/change-password endpoint instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 17:10:18 +05:00
parent c445bfacad
commit 799117d287
@@ -1,7 +1,6 @@
"use client"; "use client";
import { useState } from "react"; import { useState } from "react";
import { authClient } from "@/lib/auth-client";
const inputStyle: React.CSSProperties = { const inputStyle: React.CSSProperties = {
border: "2px solid var(--border)", border: "2px solid var(--border)",
@@ -33,14 +32,14 @@ export function ChangePasswordForm() {
} }
setLoading(true); setLoading(true);
const result = await authClient.changePassword({ const res = await fetch("/api/auth/change-password", {
currentPassword: current, method: "POST",
newPassword: next, headers: { "Content-Type": "application/json" },
revokeOtherSessions: false, body: JSON.stringify({ currentPassword: current, newPassword: next, revokeOtherSessions: false }),
}); });
setLoading(false); setLoading(false);
if (result.error) { if (!res.ok) {
setError("Неверный текущий пароль"); setError("Неверный текущий пароль");
return; return;
} }