This commit is contained in:
2024-01-15 23:44:28 +08:00
parent 0281ce9dd6
commit 7b68496aa1
8 changed files with 58 additions and 20 deletions

View File

@@ -36,10 +36,18 @@ const Login = (props: LoginProps) => {
}, [history, auth]);
const handleSubmit = async (values: any) => {
console.log(await checkUser(values));
if (await checkUser(values)) {
setAlita({ funcName: values.userName, stateName: 'auth' });
}
trailwayLogin({ username: values.userName, password: values.password }).then((res) => {
if (res.data.success) {
let user = {
uid: res.data.id,
role: res.data.role === 1 ? '系统管理员' : '访客',
roleType: res.data.role,
username: values.userName,
permissions: res.data.role === 1 ? ['auth/admin'] : [],
};
setAlita('auth', user);
}
});
};
const checkUser = async (values: any) => {
let success = await trailwayLogin({