A team brings together users who share access: a customer company, a class, a moderation crew. Each member has roles within the team (free text, such as editor or finance), and permissions can point to the whole team or just to one role.
import { ID, Teams } from '@owbase/web';import { client } from './client';
const teams = new Teams(client);
// Whoever creates the team becomes its owner ("owner" role).const team = await teams.create({ teamId: ID.unique(), name: 'Moderation' });
// Invites by email; the invitation link leads to this page of your app.await teams.createMembership({ teamId: team.$id, roles: ['editor'], email: '[email protected]', url: 'https://app.example.com/invite' });
// On the /invite page: the link arrives with ?teamId=…&membershipId=…&userId=…&secret=…const p = new URLSearchParams(window.location.search);await teams.updateMembershipStatus({ teamId: p.get('teamId') ?? '', membershipId: p.get('membershipId') ?? '', userId: p.get('userId') ?? '', secret: p.get('secret') ?? '',});
const { memberships } = await teams.listMemberships({ teamId: team.$id });console.log(memberships.map((m) => `${m.userName}: ${m.roles.join(', ')}`));Invitations
Section titled “Invitations”createMembershipwithemailcreates the membership and sends the invitation right away; it stays pending until the person accepts on theurlpage, withupdateMembershipStatus. If they don’t have an account yet, one is created along with the invitation.- From the server (
@owbase/node,teams.writescope),createMembershipwithuserIdadds the member directly, with no invitation. Withemail, the server also adds the member directly, without waiting for acceptance.
Team permissions
Section titled “Team permissions”| Permission | Who |
|---|---|
Permission.read(Role.team('t1')) |
all members of team t1 |
Permission.update(Role.team('t1', 'editor')) |
only members with the editor role |
In the console, teams are under Auth → Teams.
Was this page helpful?Thanks for your feedback.