Unverified Commit 6907961c authored by Lemon-miaow's avatar Lemon-miaow
Browse files

fix(panel): the build page trusts the server-side owner tier and drops its mock build seeds

parent d0b1f969
Loading
Loading
Loading
Loading
+5 −13
Changes for panel/src/pages/admin/ImageBuildPage.tsx: 5 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -61,7 +61,11 @@ export function ImageBuildPage() {
  const locale = i18n.language;
  const now = Date.now();
  const config = useConfig();
  const { identity } = useTier();
  // The owner tier comes from the server-side /me verdict (TierProvider), never
  // from guessing at the address: the old mock-era email heuristic misread the
  // real owner ([email protected]) as non-owner while treating any
  // "owner@…" address as one.
  const { isOwner } = useTier();

  // Form & Dialog State
  const [dialogOpen, setDialogOpen] = useState(false);
@@ -76,12 +80,6 @@ export function ImageBuildPage() {
  const [loadingSubmissions, setLoadingSubmissions] = useState(false);
  const [selectedSub, setSelectedSub] = useState<Submission | null>(null);

  const isOwner = useMemo(() => {
    if (!identity?.email) return false;
    const emailLower = identity.email.toLowerCase();
    return emailLower === "[email protected]" || emailLower.startsWith("owner@");
  }, [identity]);

  const visibleSubmissions = useMemo(() => {
    if (isOwner) {
      return submissions;
@@ -137,12 +135,6 @@ export function ImageBuildPage() {
      const stored = localStorage.getItem(LOCAL_STORAGE_KEY);
      if (stored) {
        setBuildIds(JSON.parse(stored));
      } else {
        // Seed default IDs so mock builds are loaded on first visit.
        // In production, querying these will 404 and safely show the empty state.
        const defaultIds = ["bld-1", "bld-2"];
        localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(defaultIds));
        setBuildIds(defaultIds);
      }
    } catch {
      setLoadingBuilds(false);