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 isLogged = computed(() => Number(state.userInfo?.permission) > 0);
const updateUserInfo = async (userInfo?: LoginUserInfo) => { const updateUserInfo = async (userInfo?: LoginUserInfo) => {
if (userInfo) { try {
state.userInfo = userInfo; if (userInfo) {
} else { state.userInfo = userInfo;
const info = await reqUserInfo();
if (info.value) {
state.userInfo = info.value;
} else { } 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, LockOutlined,
UserOutlined UserOutlined
} from "@ant-design/icons-vue"; } from "@ant-design/icons-vue";
import { Modal } from "ant-design-vue";
import { onMounted, reactive, ref } from "vue"; import { onMounted, reactive, ref } from "vue";
import { router } from "@/config/router"; import { router } from "@/config/router";
import { loginPageInfo, loginUser } from "@/services/apis"; import { loginPageInfo, loginUser } from "@/services/apis";
@ -50,16 +51,29 @@ const handleLogin = async () => {
...formData ...formData
} }
}); });
loginStep.value++; await handleNext();
await sleep(1200);
await updateUserInfo();
await loginSuccess();
} catch (error: any) { } catch (error: any) {
reportError(error.message ? error.message : error); reportError(error.message ? error.message : error);
loginStep.value--; 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 = () => { const loginSuccess = () => {
loginStep.value++; loginStep.value++;
if (isAdmin.value) { if (isAdmin.value) {