Skip to content
This repository was archived by the owner on Jul 27, 2026. It is now read-only.
This repository was archived by the owner on Jul 27, 2026. It is now read-only.

[Debt] AuthContext.tsx: 6 unsafe as unknown as type assertions #131

Description

@JoelA510

Summary

src/app/contexts/AuthContext.tsx has 6 as unknown as type assertions that work around mismatches between Supabase Auth SDK types and the app's AuthUser type.

Severity

Medium — type safety gap, silent failures possible if Supabase SDK changes.

Locations

Line 111: supabase.rpc('is_admin', ...) as unknown as Promise<{...}>
Line 120: supabase.rpc('is_admin', ...) as unknown as Promise<{...}>
Line 135: (session.user as unknown as Record<string, unknown>).role as string
Line 149: (session.user as unknown as Record<string, unknown>).role as string
Line 169: session as unknown as { user: User | null }
Line 171: session as unknown as { user: User | null }

Recommended Fix

  1. Create a typed Supabase helper in shared/api/ that wraps rpc() with proper generics.
  2. Extend the AuthUser type to include role from Supabase user metadata.
  3. Use a typed session wrapper instead of raw casting.

Origin

Sprint Wave 15 Code Review, §2.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions