feat: add admin auth middleware

This commit is contained in:
yanghao05
2025-04-16 20:26:02 +08:00
parent 4a9836db68
commit 92a070cc81
5 changed files with 34 additions and 13 deletions

View File

@@ -25,6 +25,10 @@ const validateForm = () => {
errorMessage.value = '请输入密码';
return false;
}
if (password.value.length < 8) {
errorMessage.value = '密码至少需要8个字符';
return false;
}
return true;
};
@@ -35,7 +39,8 @@ const handleLogin = async () => {
errorMessage.value = '';
try {
const token = await authService.login(username.value, password.value);
const resp = await authService.login(username.value, password.value);
const { token } = resp.data;
authStore.setToken(token);
router.push('/');
} catch (error) {