fix(AuthProvider): 修复认证逻辑中/api路径的检查

移除未使用密码时的直接跳转逻辑
This commit is contained in:
SongPro
2025-07-01 17:25:15 +08:00
parent 6c81f52953
commit cb8c5bfc08

View File

@@ -18,7 +18,7 @@ export default function AuthProvider({ children }: Props) {
const { siteName } = useSite();
const authenticate = useCallback(async () => {
// 登录页
if (pathname.startsWith('/login') || pathname.startsWith('/api/login')) {
if (pathname.startsWith('/login') || pathname.startsWith('/api')) {
setIsAuthenticated(true);
return;
}
@@ -30,13 +30,6 @@ export default function AuthProvider({ children }: Props) {
? window.location.pathname + window.location.search
: pathname;
// 没有密码直接跳转
if (!password) {
router.replace(`/login?redirect=${encodeURIComponent(fullPath)}`);
setIsAuthenticated(false);
return;
}
// 尝试认证
try {
const res = await fetch('/api/login', {