© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•5mo ago•
1 reply
Ahmed

Auth with roles

hello i am implement auth with roles in flutter.....i am geting the user data from the profile table...there is a role colum in there it didnt work and when i tried printing the role it said authinticated ....i have no such role in there ....this is how i am getting the data
@override
  Future<UserModel?> getCurrentUserData() async {
    try {
      final session = currentUserSession;
      if (session == null) return null;

      final userData = await supabaseClient
          .from('profiles')
          .select('id, name, role') 
          .eq('id', session.user.id);

      if (userData.isEmpty) {
        return null;
      }

      final profile = userData.first;

      return UserModel.fromJson(profile).copyWith(
        email: session.user.email,
      );
    } catch (e) {
      throw ServerException(e.toString());
    }
  }
@override
  Future<UserModel?> getCurrentUserData() async {
    try {
      final session = currentUserSession;
      if (session == null) return null;

      final userData = await supabaseClient
          .from('profiles')
          .select('id, name, role') 
          .eq('id', session.user.id);

      if (userData.isEmpty) {
        return null;
      }

      final profile = userData.first;

      return UserModel.fromJson(profile).copyWith(
        email: session.user.email,
      );
    } catch (e) {
      throw ServerException(e.toString());
    }
  }
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Question about using native PostgreSQL roles with Supabase Auth
SupabaseSSupabase / help-and-questions
4mo ago
Dealing with user roles
SupabaseSSupabase / help-and-questions
8mo ago
Steam Auth with Supabase auth.
SupabaseSSupabase / help-and-questions
2y ago
roles
SupabaseSSupabase / help-and-questions
4y ago