feat(auth): enhance password change flow and error handling
- Return response from useProfileSetting hook after password change
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user