Back

Team Invite - User automatically added to team.

  • 0
  • Teams
djcali
29 Feb, 2024, 15:20

Hello, I am using SvelteKit and trying to send a user an invitation to the team, The email gets sent but automatically added to the team. From what i understand is that using client side this should not happen only if using the server sdk.

This is my simple function used inside my +page.svelte

TypeScript
        try {
            await teamsClient.createMembership(
                teamId,
                ['staff'],
                undefined,
                id,
                undefined,
                'http://localhost:5173/team-users'
            );
        } catch (error) {
            console.log(error);
        }
    }```


This is my set up for the appwrite client:

```import { PUBLIC_APPWRITE_ENDPOINT, PUBLIC_APPWRITE_PROJECT } from "$env/static/public";
import { Client, Teams } from "appwrite"; 

// Set up client
const client = new Client();
client.setEndpoint(PUBLIC_APPWRITE_ENDPOINT).setProject(PUBLIC_APPWRITE_PROJECT);

// Set up services
export const teamsClient = new Teams(client);```

Any suggestions?
TL;DR
Developers are experiencing an issue where users are automatically added to a team without accepting the invite. The expected behavior is for users to accept or deny the request. The problem may stem from using the client-side SDK. Solution: - Check the roles of the inviting user in the team, ensuring they have an 'owner' role. - Consider switching to the server SDK instead of the client-side SDK to prevent users from being automatically added to the team. - Developers are advised to revise the flow of the app to allow users to accept or deny the team invitation.
Binyamin
29 Feb, 2024, 15:23
  • What error you're getting?
  • Does the inviting user have owner role in the team?
djcali
29 Feb, 2024, 15:25

Not getting any error. The inviting user is an owner yes.

djcali
29 Feb, 2024, 15:27

I just want the user to be able to accept or deny this request and not automatically be added.

Binyamin
29 Feb, 2024, 15:31

And the user didn't get an invite?

djcali
29 Feb, 2024, 15:40

Yes the user got the invite via email, but the user was automatically added to the team. So basically my flow in the app is that the owner of a team is signed in, and if he wants to invite a user he sends an email to join the team, but they are added immediatley after the inviteMember function is complete with out the user accepting or ignoring the request.

djcali
29 Feb, 2024, 15:45

I looked at the team and the memberships in the console, they are on the team but joined has n/a, i just don't understand why they would be on the team at all with out clicking the link to accept the invite. I did not even create the logic for the link yet anyway.

Binyamin
29 Feb, 2024, 15:45

Is the user shown as joined in the console?

djcali
29 Feb, 2024, 15:48

No it does not show joined it shows n/a, but they are listed underneath the team, so in another part of my app, i query for team members and that user does show up. Is this normal Appwrite behavior? They just stay there if they ignore the email?

djcali
29 Feb, 2024, 15:51
Binyamin
29 Feb, 2024, 15:52

No, it's not the expected behavior

Binyamin
29 Feb, 2024, 15:52

Let me check

Binyamin
29 Feb, 2024, 15:53

BTW What version of Appwrite you're using?

djcali
29 Feb, 2024, 15:53

Self Hosted 1.4.13

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