mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-03-15 18:47:28 +08:00
fix: remove no password need login
This commit is contained in:
@@ -15,19 +15,12 @@ export default function AuthProvider({ children }: Props) {
|
|||||||
// 登录页或 API 路径不做校验,避免死循环
|
// 登录页或 API 路径不做校验,避免死循环
|
||||||
if (pathname.startsWith('/login')) return;
|
if (pathname.startsWith('/login')) return;
|
||||||
|
|
||||||
const password =
|
const password = localStorage.getItem('password');
|
||||||
typeof window !== 'undefined' ? localStorage.getItem('password') : null;
|
|
||||||
const fullPath =
|
const fullPath =
|
||||||
typeof window !== 'undefined'
|
typeof window !== 'undefined'
|
||||||
? window.location.pathname + window.location.search
|
? window.location.pathname + window.location.search
|
||||||
: pathname;
|
: pathname;
|
||||||
|
|
||||||
// 没有密码直接跳转登录
|
|
||||||
if (!password) {
|
|
||||||
router.replace(`/login?redirect=${encodeURIComponent(fullPath)}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 有密码时验证
|
// 有密码时验证
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user