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:
parent
19edb1842c
commit
b0e4bc9d25
1 changed files with 4 additions and 3 deletions
|
@ -8,7 +8,8 @@ import Button from '@/components/Button';
|
||||||
import FormField from '@/components/FormField';
|
import FormField from '@/components/FormField';
|
||||||
import ModalLayout from '@/components/ModalLayout';
|
import ModalLayout from '@/components/ModalLayout';
|
||||||
import TextInput from '@/components/TextInput';
|
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 useLogtoUserId from '@/hooks/use-logto-user-id';
|
||||||
import * as modalStyles from '@/scss/modal.module.scss';
|
import * as modalStyles from '@/scss/modal.module.scss';
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ const ChangePassword = () => {
|
||||||
const { watch, register, reset } = useForm<FormFields>();
|
const { watch, register, reset } = useForm<FormFields>();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const userId = useLogtoUserId();
|
const userId = useLogtoUserId();
|
||||||
const api = useApi();
|
const api = useStaticApi({ prefixUrl: adminTenantEndpoint, resourceIndicator: meApi.indicator });
|
||||||
const password = watch('password');
|
const password = watch('password');
|
||||||
const confirmPassword = watch('confirmPassword');
|
const confirmPassword = watch('confirmPassword');
|
||||||
const isDisabled = !password || password !== confirmPassword;
|
const isDisabled = !password || password !== confirmPassword;
|
||||||
|
@ -38,7 +39,7 @@ const ChangePassword = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await api.patch(`api/users/${userId}/password`, { json: { password } }).json();
|
await api.post(`me/password`, { json: { password } }).json();
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
toast.success(t('settings.password_changed'));
|
toast.success(t('settings.password_changed'));
|
||||||
|
|
Loading…
Reference in a new issue