Skip to content
Back

Error while login the member which is in the team.

  • 1
  • Flutter
  • Auth
  • Cloud
Raman
2 Apr, 2025, 17:03

Facing some error.

Error logging in: Exception: No team access. Please contact your administrator.

But the email/name/ new client I have created is in my team.

TL;DR
Raman
2 Apr, 2025, 17:05

I have team enabled

Raman
2 Apr, 2025, 17:05

This is my team I have the client

TypeScript
  Future<appwrite_models.Membership> addMember({
    required String email,
    required String role,
    required String name,
  }) async {
    try {
      final membership = await _appwriteService.teams.createMembership(
        teamId: _currentTeam!.id,
        email: email,
        roles: [role],
        url: 'http://localhost:3000',
        name: name,
      );

      // Wait for membership to be available
      final memberships = await _appwriteService.teams.listMemberships(
        teamId: _currentTeam!.id,
      );

      final newMembership = memberships.memberships.firstWhere(
        (m) => m.$id == membership.$id,
      );

      notifyListeners();
      return newMembership;
    } catch (e) {
      rethrow;
    }
  }
Raman
2 Apr, 2025, 17:06

It's creating a new client and the client is also added to my team.

It's just that when I am trying to login what the client's email I am not able to login and getting the error

Raman
2 Apr, 2025, 17:06
TypeScript
  Future<void> login(String email, String password) async {
    try {
      await account.createEmailPasswordSession(
        email: email,
        password: password,
      );

      await _loadUserData();
      await _loadUserTeams();

      if (!hasTeamAccess) {
        // Keep user data but throw the no access exception
        notifyListeners();
        throw Exception('No team access. Please contact your administrator.');
      }

      final teamService = TeamService();
      await teamService.loadUserTeams();
      debugPrint('User logged in: ${_currentUser?.toJson()}');
      notifyListeners();
    } catch (e) {
      debugPrint('Error logging in: $e');
      if (!e.toString().contains('No team access')) {
        await logout(); // Only logout for non-team-access errors
      }
      rethrow;
    }
  }

I think I got the error

TypeScript

  Future<void> _loadUserTeams() async {
    try {
      final teamList = await teams.list();
      debugPrint('Team list: ${teamList.teams.map((t) => t.toMap())}');
      _userTeams = teamList.teams;
    } catch (e) {
      _userTeams = null;
      rethrow;
    }
  }

I am not able to get the userTeams

Which is after all getting me error

Raman
2 Apr, 2025, 17:07

when I try to create a addMember and than try to login I am facing this issue Apart from that if I try to login with the account who is the owner of the team it's works

Raman
2 Apr, 2025, 17:07

cc: @D5 @Gurjeet

Raman
2 Apr, 2025, 17:28

Error while login the member which is in the team.

Raman
2 Apr, 2025, 17:29

Error: Error logging in: Exception: No team access. Please contact your administrator.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more