Fix: banned user login

This commit is contained in:
Lazy 2024-01-13 20:41:16 +08:00
parent 8ef7cd4e4b
commit e379f71efb
2 changed files with 30 additions and 11 deletions

View File

@ -31,15 +31,20 @@ export const useAppStateStore = createGlobalState(() => {
const isLogged = computed(() => Number(state.userInfo?.permission) > 0);
const updateUserInfo = async (userInfo?: LoginUserInfo) => {
if (userInfo) {
state.userInfo = userInfo;
} else {
const info = await reqUserInfo();
if (info.value) {
state.userInfo = info.value;
try {
if (userInfo) {
state.userInfo = userInfo;
} else {
throw new Error("Failed to get user information from server!");
const info = await reqUserInfo();
if (info.value) {
state.userInfo = info.value;
} else {
throw new Error("Failed to get user information from server!");
}
}
} catch (err: any) {
console.error(err);
throw new Error(err.message);
}
};

View File

@ -7,6 +7,7 @@ import {
LockOutlined,
UserOutlined
} from "@ant-design/icons-vue";
import { Modal } from "ant-design-vue";
import { onMounted, reactive, ref } from "vue";
import { router } from "@/config/router";
import { loginPageInfo, loginUser } from "@/services/apis";
@ -50,16 +51,29 @@ const handleLogin = async () => {
...formData
}
});
loginStep.value++;
await sleep(1200);
await updateUserInfo();
await loginSuccess();
await handleNext();
} catch (error: any) {
reportError(error.message ? error.message : error);
loginStep.value--;
}
};
const handleNext = async () => {
try {
await updateUserInfo();
loginStep.value++;
await sleep(1200);
loginSuccess();
} catch (error: any) {
console.error(error);
Modal.error({
title: t("网页无法正确运作"),
content: t("无法获取身份数据,可能是您已被封禁,或者网络问题,请尝试刷新页面 ")
});
loginStep.value--;
}
};
const loginSuccess = () => {
loginStep.value++;
if (isAdmin.value) {