0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): change password should use me router api (#3214)

This commit is contained in:
Charles Zhao 2023-02-24 18:02:55 +08:00 committed by GitHub
parent 19edb1842c
commit b0e4bc9d25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,8 @@ import Button from '@/components/Button';
import FormField from '@/components/FormField';
import ModalLayout from '@/components/ModalLayout';
import TextInput from '@/components/TextInput';
import useApi from '@/hooks/use-api';
import { adminTenantEndpoint, meApi } from '@/consts';
import { useStaticApi } from '@/hooks/use-api';
import useLogtoUserId from '@/hooks/use-logto-user-id';
import * as modalStyles from '@/scss/modal.module.scss';
@ -25,7 +26,7 @@ const ChangePassword = () => {
const { watch, register, reset } = useForm<FormFields>();
const [isLoading, setIsLoading] = useState(false);
const userId = useLogtoUserId();
const api = useApi();
const api = useStaticApi({ prefixUrl: adminTenantEndpoint, resourceIndicator: meApi.indicator });
const password = watch('password');
const confirmPassword = watch('confirmPassword');
const isDisabled = !password || password !== confirmPassword;
@ -38,7 +39,7 @@ const ChangePassword = () => {
}
setIsLoading(true);
await api.patch(`api/users/${userId}/password`, { json: { password } }).json();
await api.post(`me/password`, { json: { password } }).json();
setIsLoading(false);
setIsOpen(false);
toast.success(t('settings.password_changed'));