From b0e4bc9d257dd60e8062e25c0586ec3430240dd5 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Fri, 24 Feb 2023 18:02:55 +0800 Subject: [PATCH] fix(console): change password should use me router api (#3214) --- .../src/pages/Settings/components/ChangePassword.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/console/src/pages/Settings/components/ChangePassword.tsx b/packages/console/src/pages/Settings/components/ChangePassword.tsx index 76fb2da43..8ff88ff79 100644 --- a/packages/console/src/pages/Settings/components/ChangePassword.tsx +++ b/packages/console/src/pages/Settings/components/ChangePassword.tsx @@ -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(); 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'));