static async getAuthStatus()

in app/lib/authService.ts [38:75]


  static async getAuthStatus(): Promise<AuthStatus> {
    try {
      const response = await fetch(this.API_ENDPOINT, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        credentials: "include", // Include cookies in request
        body: JSON.stringify({ action: "verify" }),
      });

      if (!response.ok) {
        throw new Error(`Auth verification failed: ${response.status}`);
      }

      const result = await response.json();

      return {
        isAuthenticated: result.isAuthenticated || false,
        hasOpenAI: result.hasOpenAI || false,
        hasHuggingFace: result.hasHuggingFace || false,
        hasGitHub: result.hasGitHub || false,
        expiresAt: result.expiresAt ? new Date(result.expiresAt) : undefined,
        hfUserInfo: result.hfUserInfo,
        githubUserInfo: result.githubUserInfo,
      };
    } catch (error) {
      console.error("Failed to get auth status:", error);
      return {
        isAuthenticated: false,
        hasOpenAI: false,
        hasHuggingFace: false,
        hasGitHub: false,
        hfUserInfo: undefined,
        githubUserInfo: undefined,
      };
    }
  }