mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-22 02:24:44 +08:00
fix(AuthProvider): 修复认证逻辑中/api路径的检查
移除未使用密码时的直接跳转逻辑
This commit is contained in:
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user