SupabaseS
Supabase4mo ago
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());
    }
  }
Was this page helpful?