Ir al contenido
v2.7

Equipos

Agrupar usuarios en equipos, invitar miembros y dar acceso por rol.

Un equipo reúne usuarios que comparten acceso: una empresa cliente, una clase, un equipo de moderación. Cada miembro tiene roles dentro del equipo (texto libre, como editor o financiero), y los permisos pueden apuntar al equipo entero o solo a un rol.

times.ts
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(', ')}`));
  • createMembership con email crea la participación y envía la invitación al instante; queda pendiente hasta que la persona acepte en la página de url, con updateMembershipStatus. Si todavía no tiene cuenta, se crea una junto con la invitación.
  • Desde el servidor (@owbase/node, alcance teams.write), createMembership con userId agrega directamente, sin invitación. Con email, el servidor también agrega directamente, sin esperar la aceptación.
Permiso Quién
Permission.read(Role.team('t1')) todos los miembros del equipo t1
Permission.update(Role.team('t1', 'editor')) solo los miembros con el rol editor

En la consola, los equipos están en Autenticación → Equipos.

¿Te ayudó esta página?