I'm using Angular on Ionic app, i'm able to create a team but i have a problem when i try to add new user to that team ; ``}
addUsertoTheTeam(){
const client = this.client.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('****************');
const teams = new Teams(client);
teams.createMembership('***************',[
'email','**********************@gmail.com',
'roles', Role.member('**********************'),
Permission.read(Role.team("*****************")),
Permission.update(Role.team("***************", "owner")),
Permission.delete(Role.team("******************", "owner"))
]).then(response=> {
console.log('member created : ', response);
}, function (error) {
console.log('error on created team', error);
});
}``
What's the problem here?
roles
is an array, I don't think it will take email
.
I think the docs are missing something. Give me a minute
Can you try this?
const promise = await teams.createMembership(
'[TEAM_ID]',
'email@example.com',
[
// add roles here
]
);
Should be something like this:
await teams.createMembership('teamId', [
sdk.Role.user('userIdOne'),
sdk.Role.user('userIdTwo'),
sdk.Role.user('userIdThree'),
], 'xyz@gmail.com');
This is what I can understand from the source.
I haven't used the createMembership endpoint in 1.4, so not sure what the correct syntax is.
The request params specify, in the same order:
- userId
- phone
- roles (required)
- url
- name
So I assumed the email comes before the roles
Signature is changed
async createMembership(teamId, roles, email, userId, phone, url, name) {}
OP has added the email
& roles
inside the array
.
Also, I'm not sure how permissions come into play here.
Doc. doesn't seem to be correct.
A issue would be good for this I think.
The docs. seem to be fixed now.
can you help me with some eg
FYI, it's best to use 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
an example was given here: https://discord.com/channels/564160730845151244/1159048444195905546/1159050686760239145.
i mean server side please
It's the same API/method
I saw a method to add user to the team without sending email
I tried many method till doday, i'm not able
Client sided is exactly the same way steven suggested. Make sure you have the API key stablished with the corresponding scopes
Yes, that one is exclusive for server side use
Recommended threads
- self-hosted auth: /v1/account 404 on saf...
Project created in React/Next.js, Appwrite version 1.6.0. Authentication works in all browsers except Safari (ios), where an attempt to connect to {endpoint}/v1...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...