mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-22 06:17:29 +08:00
fix(AuthProvider): 修复认证逻辑中/api路径的检查
移除未使用密码时的直接跳转逻辑
This commit is contained in:
@@ -18,7 +18,7 @@ export default function AuthProvider({ children }: Props) {
|
|||||||
const { siteName } = useSite();
|
const { siteName } = useSite();
|
||||||
const authenticate = useCallback(async () => {
|
const authenticate = useCallback(async () => {
|
||||||
// 登录页
|
// 登录页
|
||||||
if (pathname.startsWith('/login') || pathname.startsWith('/api/login')) {
|
if (pathname.startsWith('/login') || pathname.startsWith('/api')) {
|
||||||
setIsAuthenticated(true);
|
setIsAuthenticated(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -30,13 +30,6 @@ export default function AuthProvider({ children }: Props) {
|
|||||||
? window.location.pathname + window.location.search
|
? window.location.pathname + window.location.search
|
||||||
: pathname;
|
: pathname;
|
||||||
|
|
||||||
// 没有密码直接跳转
|
|
||||||
if (!password) {
|
|
||||||
router.replace(`/login?redirect=${encodeURIComponent(fullPath)}`);
|
|
||||||
setIsAuthenticated(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 尝试认证
|
// 尝试认证
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/login', {
|
const res = await fetch('/api/login', {
|
||||||
|
|||||||
Reference in New Issue
Block a user