소스 검색

fix: cached localStorage user not recognized without apigId - prevent redundant login

gangvy 5 달 전
부모
커밋
ae2dbf193a
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      src/app/app.ts

+ 4 - 3
src/app/app.ts

@@ -112,12 +112,13 @@ export class App implements OnInit {
       console.log('[AUTH] 从 localStorage 恢复用户:', cachedUserId);
       this.userId = cachedUserId;
       this.loggedInUser = cachedUserId;
+      // 后台验证 token 是否还有效
+      this.validateCachedToken(cachedToken, cachedUserId);
       if (this.apigId) {
         this.loadApig();
-        // 后台验证 token 是否还有效
-        this.validateCachedToken(cachedToken, cachedUserId);
-        return;
       }
+      // 即使没有 apigId,也不需要重新登录(模板会显示友好提示)
+      return;
     }
 
     // 3. 什么都没有 → 显示登录弹窗