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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user