feat(auth): enhance password change flow and error handling

- Return response from useProfileSetting hook after password change
This commit is contained in:
2025-11-19 17:43:45 +08:00
parent d84fd8934e
commit 83df8a7373
10 changed files with 59 additions and 21 deletions

View File

@@ -7,11 +7,14 @@ import ChangePasswordDialog from "./components/ChangePasswordDialog";
import { useProfileSetting } from "@/hooks/setting-hooks";
import logger from "@/utils/logger";
import { useUserData } from "@/hooks/useUserData";
import { useAuth } from '@/hooks/login-hooks';
import { useNavigate } from "react-router-dom";
function ProfileSetting() {
const { t } = useTranslation();
const { userInfo, updateUserInfo: updateUserInfoFunc, changeUserPassword: changeUserPasswordFunc } = useProfileSetting();
const { refreshUserData } = useUserData();
const { logout } = useAuth();
const [passwordDialogOpen, setPasswordDialogOpen] = useState(false);
logger.debug('userInfo', userInfo);
@@ -66,6 +69,10 @@ function ProfileSetting() {
<ChangePasswordDialog
open={passwordDialogOpen}
onClose={handleClosePasswordDialog}
onSuccess={() => {
// 使用 useAuth 的 logout确保清除本地存储令牌并跳转登录
logout();
}}
changeUserPassword={changeUserPasswordFunc}
/>
</Box>