Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

feat: suggest people by name or address in the team invite dialog (#717)

Gourav Kumar Dhimand5e0e5f93f0a
diff --git a/apps/api/src/modules/agents/chat-history.ts b/apps/api/src/modules/agents/chat-history.ts
index 7c800e91..d6c91b43 100644
--- a/apps/api/src/modules/agents/chat-history.ts
+++ b/apps/api/src/modules/agents/chat-history.ts
@@ -45,12 +45,6 @@ export function searchTerm(q: string | undefined): string | null {
return trimmed.length >= MIN_QUERY ? trimmed : null;
}
-// The ILIKE pattern for the term. The wildcards a member types are escaped, so a query
-// with a % in it looks for that character.
-export function likePattern(term: string): string {
- return `%${term.replace(/([\\%_])/g, '\\$1')}%`;
-}
-
// The stretch of text around the first match, cut in the database: an answer can be
// 100,000 characters and must not be read into the app to show 160 of them.
export function snippetOf(text: SQL, term: string): SQL {
diff --git a/apps/api/src/modules/agents/chat/service.ts b/apps/api/src/modules/agents/chat/service.ts
index fa17fe88..fded2907 100644
--- a/apps/api/src/modules/agents/chat/service.ts
+++ b/apps/api/src/modules/agents/chat/service.ts
@@ -1,11 +1,10 @@
import { db, agentChatEvent, agentChatFavorite, agentChatMessage, agentChatThread } from '@repo/db';
import { and, asc, desc, eq, gt, inArray, notExists, sql } from 'drizzle-orm';
import { setTimeout as sleep } from 'node:timers/promises';
-import { intEnv, iso } from '#shared/lib';
+import { intEnv, iso, likePattern } from '#shared/lib';
import { deleteContextUsage, recordContextUsage, type ContextUsage } from '../chat-usage';
import { deleteFavorite, FAVORITES_LIMIT } from '../chat-favorites';
import {
- likePattern,
searchTerm,
snippetOf,
summarize,
diff --git a/apps/api/src/modules/agents/core/runtime/memory.ts b/apps/api/src/modules/agents/core/runtime/memory.ts
index f57653ce..08fe0555 100644
--- a/apps/api/src/modules/agents/core/runtime/memory.ts
+++ b/apps/api/src/modules/agents/core/runtime/memory.ts
@@ -1,6 +1,7 @@
import { Memory } from '@mastra/memory';
import { db } from '@repo/db';
import { sql } from 'drizzle-orm';
+import { likePattern } from '#shared/lib';
import { appendTextPart, toolArgsText, toolText } from '../../chat-parts';
import { deleteContextUsage } from '../../chat-usage';
import {
@@ -10,7 +11,6 @@ import {
FAVORITES_LIMIT,
} from '../../chat-favorites';
import {
- likePattern,
searchTerm,
snippetOf,
summarize,
diff --git a/apps/api/src/modules/god/model.ts b/apps/api/src/modules/god/model.ts
index 7a54ed1e..f53b6e0c 100644
--- a/apps/api/src/modules/god/model.ts
+++ b/apps/api/src/modules/god/model.ts
@@ -50,6 +50,7 @@ export const AuthSettingsResponse = t.Object({
trustProviderEmails: t.Boolean(),
personalWorkspaces: t.Boolean(),
inviteTtlDays: t.Integer(),
+ inviteSearch: t.Boolean(),
allowedEmailDomains: t.Array(t.String()),
// The settings that depend on outbound email cannot be turned on without a mail
// provider, and the UI explains why.
@@ -70,6 +71,7 @@ export const AuthSettingsBody = t.Object({
personalWorkspaces: t.Optional(t.Boolean()),
// The cap keeps createdAt plus the lifetime inside the range a Date can hold.
inviteTtlDays: t.Optional(t.Integer({ minimum: 0, maximum: 3650 })),
+ inviteSearch: t.Optional(t.Boolean()),
allowedEmailDomains: t.Optional(EmailDomains),
});
diff --git a/apps/api/src/modules/invites/__tests__/integration/invite-candidates.test.ts b/apps/api/src/modules/invites/__tests__/integration/invite-candidates.test.ts
new file mode 100644
index 00000000..36f682a1
--- /dev/null
+++ b/apps/api/src/modules/invites/__tests__/integration/invite-candidates.test.ts
@@ -0,0 +1,140 @@
+import { describe, it, expect, beforeEach } from 'bun:test';
+import { authedApi, createProject, type Api } from '#tests/helpers/app';
+import { createAgent } from '#tests/helpers/agents';
+import { signUpTestUser } from '#tests/helpers/auth';
+import { resetDb } from '#tests/helpers/db';
+
+async function ownTeamId(api: Api): Promise<number> {
+ const teams = await api.teams.get();
+ return teams.data!.find((one) => one.role === 'owner')!.id;
+}
+
+// The first account is the instance owner, so it may set the search in god mode.
+async function setupOwner(inviteSearch = true) {
+ const owner = await signUpTestUser({ name: 'Olivia Owner', email: '[email protected]' });
+ const api = authedApi(owner.cookie);
+ await api.god['auth-settings'].put({ inviteSearch });
+ return { api, teamId: await ownTeamId(api) };
+}
+
+async function joinTeam(
+ owner: Awaited<ReturnType<typeof setupOwner>>,
+ role: 'manager' | 'member',
+ person: { name: string; email: string },
+) {
+ const user = await signUpTestUser(person);
+ const invite = await owner.api
+ .teams({ teamId: owner.teamId })
+ .invites.post({ email: user.email, role });
+ const api = authedApi(user.cookie);
+ await api.invites({ token: invite.data!.token }).accept.post();
+ return api;
+}
+
+const search = (api: Api, teamId: number, term: string) =>
+ api.teams({ teamId }).invites.candidates.get({ query: { search: term } });
+
+const emails = (items: { email: string }[] | null) => (items ?? []).map((one) => one.email);
+
+describe('invite candidates — GET /teams/:teamId/invites/candidates', () => {
+ beforeEach(async () => {
+ await resetDb();
+ });
+
+ it('is refused while the instance has the search off, which is the default', async () => {
+ const owner = await setupOwner(false);
+ await signUpTestUser({ name: 'Nina New', email: '[email protected]' });
+
+ expect((await search(owner.api, owner.teamId, 'nina')).status).toBe(403);
+ expect((await owner.api.settings['invite-search'].get()).data).toEqual({ enabled: false });
+
+ await owner.api.god['auth-settings'].put({ inviteSearch: true });
+ expect((await owner.api.settings['invite-search'].get()).data).toEqual({ enabled: true });
+ expect(emails((await search(owner.api, owner.teamId, 'nina')).data)).toEqual(['[email protected]']);
+ });
+
+ it('matches part of the name or the address, ignoring case', async () => {
+ const owner = await setupOwner();
+ const ada = await signUpTestUser({ name: 'Ada Lovelace', email: '[email protected]' });
+ await signUpTestUser({ name: 'Grace Hopper', email: '[email protected]' });
+
+ const byName = await search(owner.api, owner.teamId, 'LOVE');
+ expect(byName.status).toBe(200);
+ expect(byName.data).toEqual([
+ { userId: ada.userId, name: 'Ada Lovelace', email: '[email protected]', image: null },
+ ]);
+
+ const byEmail = await search(owner.api, owner.teamId, 'navy.te');
+ expect(emails(byEmail.data)).toEqual(['[email protected]']);
+ });
+
+ it('leaves out the members of the team and the AI agents', async () => {
+ const owner = await setupOwner();
+ await joinTeam(owner, 'member', { name: 'Sam Member', email: '[email protected]' });
+ await signUpTestUser({ name: 'Sam Outsider', email: '[email protected]' });
+ const other = await signUpTestUser({ name: 'Other Owner', email: '[email protected]' });
+ const otherApi = authedApi(other.cookie);
+ await createProject(otherApi, { key: 'OTH', name: 'Other' });
+ const agent = await createAgent(otherApi, 'OTH', {
+ name: 'Sam Bot',
+ username: 'sambot',
+ kind: 'external',
+ });
+ expect(agent.status).toBe(201);
+
+ const res = await search(owner.api, owner.teamId, 'sam');
+ expect(emails(res.data)).toEqual(['[email protected]']);
+ expect(emails((await search(owner.api, owner.teamId, 'olivia')).data)).toEqual([]);
+ });
+
+ it('answers with at most 8 people', async () => {
+ const owner = await setupOwner();
+ for (let i = 1; i <= 9; i++) {
+ await signUpTestUser({ name: `Crowd ${i}`, email: `crowd-${i}@many.test` });
+ }
+
+ const res = await search(owner.api, owner.teamId, 'crowd');
+ expect(res.status).toBe(200);
+ expect(res.data).toHaveLength(8);
+ });
+
+ it('needs at least 2 characters', async () => {
+ const owner = await setupOwner();
+ await signUpTestUser({ name: 'Al Short', email: '[email protected]' });
+
+ expect((await search(owner.api, owner.teamId, 'a')).status).toBe(400);
+ expect((await search(owner.api, owner.teamId, '')).status).toBe(400);
+ expect(emails((await search(owner.api, owner.teamId, 'al')).data)).toEqual(['[email protected]']);
+ });
+
+ it('matches % and _ literally', async () => {
+ const owner = await setupOwner();
+ await signUpTestUser({ name: 'Rate 100% Sure', email: '[email protected]' });
+ await signUpTestUser({ name: 'Rate 1000 Sure', email: '[email protected]' });
+ await signUpTestUser({ name: 'snake_case', email: '[email protected]' });
+ await signUpTestUser({ name: 'snakeXcase', email: '[email protected]' });
+
+ expect(emails((await search(owner.api, owner.teamId, '100%')).data)).toEqual([
+ ]);
+ expect(emails((await search(owner.api, owner.teamId, 'e_c')).data)).toEqual([
+ ]);
+ });
+
+ it('is open to a manager and refused to a plain member', async () => {
+ const owner = await setupOwner();
+ const manager = await joinTeam(owner, 'manager', {
+ name: 'Mia Manager',
+ email: '[email protected]',
+ });
+ const member = await joinTeam(owner, 'member', { name: 'Max Member', email: '[email protected]' });
+ await signUpTestUser({ name: 'Nina New', email: '[email protected]' });
+
+ const byManager = await search(manager, owner.teamId, 'nina');
+ expect(emails(byManager.data)).toEqual(['[email protected]']);
+
+ const byMember = await search(member, owner.teamId, 'nina');
+ expect(byMember.status).toBe(403);
+ });
+});
diff --git a/apps/api/src/modules/invites/index.ts b/apps/api/src/modules/invites/index.ts
index a66886c9..ec79c142 100644
--- a/apps/api/src/modules/invites/index.ts
+++ b/apps/api/src/modules/invites/index.ts
@@ -28,6 +28,8 @@ import {
InviteViewResponse,
createInviteBody,
createTeamInviteBody,
+ inviteCandidatesQuery,
+ InviteCandidateListResponse,
inviteParams,
teamInviteParams,
tokenParams,
@@ -38,6 +40,7 @@ import {
mayGrantInviteRanks,
listProjectInvites,
listTeamInvites,
+ listInviteCandidates,
type ListedInvite,
deleteProjectInvite,
deleteTeamInvite,
@@ -383,6 +386,24 @@ export const inviteRoutes = new Elysia({ name: 'invites', detail: { tags: ['Invi
},
)
+ .get(
+ '/teams/:teamId/invites/candidates',
+ ({ membership, query }) => listInviteCandidates(membership.teamId, query.search),
+ {
+ teamManager: true,
+ params: teamParams,
+ query: inviteCandidatesQuery,
+ response: { 200: InviteCandidateListResponse, ...commonErrors },
+ detail: {
+ summary: 'Search people to invite to a team',
+ description:
+ 'Up to 8 accounts of the instance whose name or address contains the search, ' +
+ 'leaving out the members of the team and the AI agents. Whoever may invite to the ' +
+ 'team may search, while the instance owner has the search turned on.',
+ },
+ },
+ )
+
// The team list also shows the invites that name one of its projects, so this mails
// those too, as their project would.
.post(
diff --git a/apps/api/src/modules/invites/model.ts b/apps/api/src/modules/invites/model.ts
index f40b6765..dd7c6af5 100644
--- a/apps/api/src/modules/invites/model.ts
+++ b/apps/api/src/modules/invites/model.ts
@@ -26,6 +26,23 @@ export const createTeamInviteBody = t.Object({
role: teamRole,
});
+export const inviteCandidatesQuery = t.Object({
+ search: t.String({
+ minLength: 2,
+ maxLength: 200,
+ description: 'Part of the name or the address, at least 2 characters.',
+ }),
+});
+
+export const InviteCandidateListResponse = t.Array(
+ t.Object({
+ userId: t.String(),
+ name: t.String(),
+ email: t.String(),
+ image: t.Nullable(t.String()),
+ }),
+);
+
// The manager-facing invite row (ListedInvite from the service).
export const InviteRowResponse = t.Object({
id: t.Number(),
diff --git a/apps/api/src/modules/invites/service.ts b/apps/api/src/modules/invites/service.ts
index c181048c..343513bc 100644
--- a/apps/api/src/modules/invites/service.ts
+++ b/apps/api/src/modules/invites/service.ts
@@ -1,7 +1,30 @@
-import { db, teamInvite, teamMember, projectMember, teamRole, team, project, user } from '@repo/db';
-import { and, desc, eq, gte, inArray, isNull, lt, sql } from 'drizzle-orm';
+import {
+ db,
+ aiAgent,
+ teamInvite,
+ teamMember,
+ projectMember,
+ teamRole,
+ team,
+ project,
+ user,
+} from '@repo/db';
+import {
+ and,
+ asc,
+ desc,
+ eq,
+ gte,
+ ilike,
+ inArray,
+ isNull,
+ lt,
+ notExists,
+ or,
+ sql,
+} from 'drizzle-orm';
import { getAuthSettings, inviteValidSince } from '@repo/auth';
-import { HttpError, iso, pgErrorCode } from '#shared/lib';
+import { HttpError, iso, likePattern, pgErrorCode } from '#shared/lib';
import { getProjectAccess, getTeamAccess } from '#shared/access';
import { teamRef } from '#modules/teams/ref';
import { getMembership, type MemberRole } from '#modules/members/service';
@@ -327,6 +350,38 @@ export async function listTeamInvites(teamId: number, issuerId: string): Promise
return toListed(rows, issuerId);
}
+const INVITE_CANDIDATE_LIMIT = 8;
+
+// The whole instance is searched: an invitee is not in the team yet.
+export async function listInviteCandidates(teamId: number, search: string) {
+ if (!(await getAuthSettings()).inviteSearch) {
+ throw new HttpError(403, 'Searching people is turned off on this instance');
+ }
+ const pattern = likePattern(search);
+ return db
+ .select({ userId: user.id, name: user.name, email: user.email, image: user.image })
+ .from(user)
+ .where(
+ and(
+ or(ilike(user.name, pattern), ilike(user.email, pattern)),
+ notExists(
+ db
+ .select({ one: sql`1` })
+ .from(teamMember)
+ .where(and(eq(teamMember.teamId, teamId), eq(teamMember.userId, user.id))),
+ ),
+ notExists(
+ db
+ .select({ one: sql`1` })
+ .from(aiAgent)
+ .where(eq(aiAgent.userId, user.id)),
+ ),
+ ),
+ )
+ .orderBy(asc(user.name), asc(user.email))
+ .limit(INVITE_CANDIDATE_LIMIT);
+}
+
// Removes an invite of the given project. Returns true when one existed. Used to
// revoke a pending invite or clean up a resolved one.
export async function deleteProjectInvite(projectId: number, id: number): Promise<boolean> {
diff --git a/apps/api/src/modules/settings/index.ts b/apps/api/src/modules/settings/index.ts
index 192bc858..47030118 100644
--- a/apps/api/src/modules/settings/index.ts
+++ b/apps/api/src/modules/settings/index.ts
@@ -3,11 +3,13 @@ import { requireUser } from '#shared/access';
import { authContext } from '#shared/auth-context';
import { errors } from '#shared/responses';
import { getStorageSettings } from '@repo/db';
+import { getAuthSettings } from '@repo/auth';
import { getHotkeySettings } from './service';
import { getAppVersion } from './updates';
import { getWhatsNew, markWhatsNewSeen } from './whats-new';
import {
HotkeyCombosSchema,
+ InviteSearchSchema,
StorageSettingsSchema,
VersionResponse,
WhatsNewSchema,
@@ -40,6 +42,19 @@ export const settingsRoutes = new Elysia({
},
})
+ .get(
+ '/settings/invite-search',
+ async () => ({ enabled: (await getAuthSettings()).inviteSearch }),
+ {
+ response: { 200: InviteSearchSchema, ...errors(401) },
+ detail: {
+ summary: 'Get whether people can be searched when inviting',
+ description:
+ 'Get whether the invite dialog of a team may look up accounts of this instance by name or address. Changing it is god mode.',
+ },
+ },
+ )
+
// The running version, shown in the sidebar to everyone. Whether a newer one
// exists is god mode (/god/updates), and so is the release history. A session is
// required: the version tells an anonymous visitor which release to look up
diff --git a/apps/api/src/modules/settings/model.ts b/apps/api/src/modules/settings/model.ts
index 96ed69bb..d9d62768 100644
--- a/apps/api/src/modules/settings/model.ts
+++ b/apps/api/src/modules/settings/model.ts
@@ -8,6 +8,8 @@ export const StorageSettingsSchema = t.Object({
projectQuotaMb: t.Number(),
});
+export const InviteSearchSchema = t.Object({ enabled: t.Boolean() });
+
export const ProjectDefaultsSchema = t.Object({
mcpEnabled: t.Boolean(),
});
diff --git a/apps/api/src/shared/lib.ts b/apps/api/src/shared/lib.ts
index 5627fb79..123972b4 100644
--- a/apps/api/src/shared/lib.ts
+++ b/apps/api/src/shared/lib.ts
@@ -51,6 +51,12 @@ export function escapeHtml(s: string): string {
.replace(/'/g, '&#39;');
}
+// The ILIKE pattern for the term. The wildcards a member types are escaped, so a query
+// with a % in it looks for that character.
+export function likePattern(term: string): string {
+ return `%${term.replace(/([\\%_])/g, '\\$1')}%`;
+}
+
// The Postgres SQLSTATE of a driver error. Drizzle wraps the driver error in a
// DrizzleQueryError with the original as `.cause`, so the code may be one level
// down; unwrap the cause chain to find it.
diff --git a/apps/web/messages/ar/god.json b/apps/web/messages/ar/god.json
index c3131279..b0df9c65 100644
--- a/apps/web/messages/ar/god.json
+++ b/apps/web/messages/ar/god.json
@@ -179,6 +179,10 @@
"workspaces": "مساحات العمل",
"personalWorkspaces": "مساحة عمل لكل شخص",
"personalWorkspacesHint": "كل حساب بياخد مساحة عمل خاصة بيه باسم صاحبه. لو اتقفل، الناس بيشتغلوا بس في مساحات العمل اللي اتضافوا ليها.",
+ "invites": "الدعوات",
+ "inviteSearch": "اقتراح أشخاص عند الدعوة",
+ "inviteSearchHint": "لما مالك الفريق أو مديره يكتب عنوان في نافذة الدعوة، بتظهر الحسابات المطابقة من كل مساحات العمل على النسخة دي بالاسم والإيميل. لو اتقفل، لازم يكتب العنوان كامل.",
+ "invitesSaved": "اتحفظت إعدادات الدعوات",
"agents": "الوكلاء",
"agentsSaved": "تم حفظ إعدادات الوكلاء",
"embedding": "التضمين",
diff --git a/apps/web/messages/en/god.json b/apps/web/messages/en/god.json
index 27d5ceb1..ad8b1c03 100644
--- a/apps/web/messages/en/god.json
+++ b/apps/web/messages/en/god.json
@@ -179,6 +179,10 @@
"workspaces": "Workspaces",
"personalWorkspaces": "A workspace for everyone",
"personalWorkspacesHint": "Every account gets a workspace of its own, named after the person. Off, people work only in the workspaces they are added to.",
+ "invites": "Invites",
+ "inviteSearch": "Suggest people when inviting",
+ "inviteSearchHint": "As a team owner or manager types an address in the invite dialog, matching accounts from every workspace on this instance are listed by name and email. Off, they type the full address.",
+ "invitesSaved": "Invite settings saved",
"agents": "Agents",
"agentsSaved": "Agent settings saved",
"embedding": "Embedding",
diff --git a/apps/web/messages/es-ES/god.json b/apps/web/messages/es-ES/god.json
index cd40cc45..9da423eb 100644
--- a/apps/web/messages/es-ES/god.json
+++ b/apps/web/messages/es-ES/god.json
@@ -179,6 +179,10 @@
"workspaces": "Espacios de trabajo",
"personalWorkspaces": "Un espacio de trabajo para cada persona",
"personalWorkspacesHint": "Cada cuenta recibe un espacio de trabajo propio con el nombre de la persona. Desactivado, cada persona trabaja solo en los espacios de trabajo a los que se le ha añadido.",
+ "invites": "Invitaciones",
+ "inviteSearch": "Sugerir personas al invitar",
+ "inviteSearchHint": "Cuando un propietario o gestor de un equipo escribe una dirección en el diálogo de invitación, se muestran por nombre y email las cuentas que coinciden de todos los espacios de trabajo de esta instancia. Desactivado, hay que escribir la dirección completa.",
+ "invitesSaved": "Ajustes de invitaciones guardados",
"agents": "Agentes",
"agentsSaved": "Ajustes de agentes guardados",
"embedding": "Inserción",
diff --git a/apps/web/messages/fa/god.json b/apps/web/messages/fa/god.json
index b2f88f2e..1a5891d9 100644
--- a/apps/web/messages/fa/god.json
+++ b/apps/web/messages/fa/god.json
@@ -179,6 +179,10 @@
"workspaces": "فضاهای کار",
"personalWorkspaces": "فضای کار برای همه",
"personalWorkspacesHint": "هر حساب یک فضای کار اختصاصی به نام خود فرد می‌گیرد. در حالت خاموش، افراد فقط در فضاهای کاری که به آن‌ها اضافه شده‌اند کار می‌کنند.",
+ "invites": "دعوت‌ها",
+ "inviteSearch": "پیشنهاد افراد هنگام دعوت",
+ "inviteSearchHint": "وقتی مالک یا مدیر تیم نشانی را در پنجره دعوت تایپ می‌کند، حساب‌های منطبق از همه فضاهای کاری این نمونه با نام و ایمیل نمایش داده می‌شوند. در حالت خاموش، باید نشانی کامل را تایپ کرد.",
+ "invitesSaved": "تنظیمات دعوت ذخیره شد",
"agents": "ایجنت‌ها",
"agentsSaved": "تنظیمات ایجنت ذخیره شد",
"embedding": "جاسازی",
diff --git a/apps/web/messages/fr/god.json b/apps/web/messages/fr/god.json
index f1a68306..af576dee 100644
--- a/apps/web/messages/fr/god.json
+++ b/apps/web/messages/fr/god.json
@@ -179,6 +179,10 @@
"workspaces": "Espaces de travail",
"personalWorkspaces": "Un espace de travail pour chacun",
"personalWorkspacesHint": "Chaque compte reçoit son propre espace de travail, à son nom. Désactivé, chacun travaille seulement dans les espaces de travail où il a été ajouté.",
+ "invites": "Invitations",
+ "inviteSearch": "Suggérer des personnes lors d'une invitation",
+ "inviteSearchHint": "Quand un propriétaire ou un gestionnaire d'équipe saisit une adresse dans la fenêtre d'invitation, les comptes correspondants de tous les espaces de travail de cette instance s'affichent avec leur nom et leur email. Désactivé, il faut saisir l'adresse complète.",
+ "invitesSaved": "Paramètres des invitations enregistrés",
"agents": "Agents",
"agentsSaved": "Paramètres des agents enregistrés",
"embedding": "Intégration",
diff --git a/apps/web/messages/id/god.json b/apps/web/messages/id/god.json
index 121a392c..cc35f9b8 100644
--- a/apps/web/messages/id/god.json
+++ b/apps/web/messages/id/god.json
@@ -179,6 +179,10 @@
"workspaces": "Workspace",
"personalWorkspaces": "Workspace untuk setiap orang",
"personalWorkspacesHint": "Setiap akun mendapat workspace sendiri dengan nama pemiliknya. Jika nonaktif, orang hanya bekerja di workspace tempat mereka ditambahkan.",
+ "invites": "Undangan",
+ "inviteSearch": "Sarankan orang saat mengundang",
+ "inviteSearchHint": "Saat pemilik atau manajer tim mengetik alamat di dialog undangan, akun yang cocok dari semua workspace di instance ini ditampilkan dengan nama dan email. Jika nonaktif, alamat harus diketik lengkap.",
+ "invitesSaved": "Pengaturan undangan disimpan",
"agents": "Agen",
"agentsSaved": "Pengaturan agen disimpan",
"embedding": "Penyematan",
diff --git a/apps/web/messages/ko/god.json b/apps/web/messages/ko/god.json
index f1ab6106..6f040069 100644
--- a/apps/web/messages/ko/god.json
+++ b/apps/web/messages/ko/god.json
@@ -179,6 +179,10 @@
"workspaces": "워크스페이스",
"personalWorkspaces": "모든 사용자에게 워크스페이스 제공",
"personalWorkspacesHint": "각 계정에 사용자 이름을 딴 개인 워크스페이스가 하나씩 생성됩니다. 끄면 사용자는 자신이 추가된 워크스페이스에서만 작업할 수 있습니다.",
+ "invites": "초대",
+ "inviteSearch": "초대할 때 사용자 추천",
+ "inviteSearchHint": "팀 소유자나 관리자가 초대 창에 주소를 입력하면 이 인스턴스의 모든 워크스페이스에서 일치하는 계정이 이름과 이메일로 표시됩니다. 끄면 전체 주소를 입력해야 합니다.",
+ "invitesSaved": "초대 설정이 저장되었습니다",
"agents": "AI 에이전트",
"agentsSaved": "AI 에이전트 설정이 저장되었습니다",
"embedding": "임베드",
diff --git a/apps/web/messages/pt-BR/god.json b/apps/web/messages/pt-BR/god.json
index c5b2ecee..d01f2a14 100644
--- a/apps/web/messages/pt-BR/god.json
+++ b/apps/web/messages/pt-BR/god.json
@@ -179,6 +179,10 @@
"workspaces": "Workspaces",
"personalWorkspaces": "Um workspace para cada pessoa",
"personalWorkspacesHint": "Cada conta recebe um workspace próprio com o nome da pessoa. Desativado, as pessoas trabalham apenas nos workspaces aos quais foram adicionadas.",
+ "invites": "Convites",
+ "inviteSearch": "Sugerir pessoas ao convidar",
+ "inviteSearchHint": "Quando um proprietário ou gerente de equipe digita um endereço na janela de convite, as contas correspondentes de todos os workspaces desta instância aparecem com nome e email. Desativado, é preciso digitar o endereço completo.",
+ "invitesSaved": "Configurações de convites salvas",
"agents": "Agentes",
"agentsSaved": "Configurações de agentes salvas",
"embedding": "Incorporação",
diff --git a/apps/web/messages/ru/god.json b/apps/web/messages/ru/god.json
index b835c9e6..ad0024ea 100644
--- a/apps/web/messages/ru/god.json
+++ b/apps/web/messages/ru/god.json
@@ -179,6 +179,10 @@
"workspaces": "Воркспейсы",
"personalWorkspaces": "Воркспейс для каждого",
"personalWorkspacesHint": "Каждый аккаунт получает свой воркспейс с именем человека. Если выключено, люди работают только в воркспейсах, куда их добавили.",
+ "invites": "Приглашения",
+ "inviteSearch": "Подсказывать людей при приглашении",
+ "inviteSearchHint": "Когда владелец или менеджер команды вводит адрес в окне приглашения, под полем появляются подходящие аккаунты из всех воркспейсов инстанса, с именем и email. Если выключено, нужно ввести адрес целиком.",
+ "invitesSaved": "Настройки приглашений сохранены",
"agents": "Агенты",
"agentsSaved": "Настройки агентов сохранены",
"embedding": "Встраивание",
diff --git a/apps/web/messages/tr/god.json b/apps/web/messages/tr/god.json
index 8d86b437..4d7fae9b 100644
--- a/apps/web/messages/tr/god.json
+++ b/apps/web/messages/tr/god.json
@@ -179,6 +179,10 @@
"workspaces": "Çalışma Alanları",
"personalWorkspaces": "Herkes için bir çalışma alanı",
"personalWorkspacesHint": "Her hesaba kullanıcının adını taşıyan kendine ait bir çalışma alanı verilir. Kapalıyken kişiler yalnızca eklendikleri çalışma alanlarında çalışabilir.",
+ "invites": "Davetler",
+ "inviteSearch": "Davet ederken kişi öner",
+ "inviteSearchHint": "Bir ekip sahibi veya yöneticisi davet penceresine adres yazarken, bu örnekteki tüm çalışma alanlarından eşleşen hesaplar ad ve e-posta ile listelenir. Kapalıyken adresin tamamı yazılmalıdır.",
+ "invitesSaved": "Davet ayarları kaydedildi",
"agents": "Ajanlar",
"agentsSaved": "Ajan ayarları kaydedildi",
"embedding": "Yerleştirme",
diff --git a/apps/web/messages/uk/god.json b/apps/web/messages/uk/god.json
index 79c668c0..ec26e16e 100644
--- a/apps/web/messages/uk/god.json
+++ b/apps/web/messages/uk/god.json
@@ -179,6 +179,10 @@
"workspaces": "Воркспейси",
"personalWorkspaces": "Воркспейс для кожного",
"personalWorkspacesHint": "Кожен акаунт отримує свій воркспейс з ім'ям людини. Якщо вимкнено, люди працюють лише у воркспейсах, до яких їх додали.",
+ "invites": "Запрошення",
+ "inviteSearch": "Підказувати людей під час запрошення",
+ "inviteSearchHint": "Коли власник або менеджер команди вводить адресу у вікні запрошення, під полем з'являються відповідні акаунти з усіх воркспейсів інстансу, з ім'ям та email. Якщо вимкнено, потрібно ввести адресу повністю.",
+ "invitesSaved": "Налаштування запрошень збережено",
"agents": "Агенти",
"agentsSaved": "Налаштування агентів збережено",
"embedding": "Вбудовування",
diff --git a/apps/web/messages/zh-CN/god.json b/apps/web/messages/zh-CN/god.json
index 642af0b8..cd09f813 100644
--- a/apps/web/messages/zh-CN/god.json
+++ b/apps/web/messages/zh-CN/god.json
@@ -179,6 +179,10 @@
"workspaces": "工作区",
"personalWorkspaces": "每人一个工作区",
"personalWorkspacesHint": "每个账户都会获得一个以其姓名命名的专属工作区。关闭后,成员只能在被添加到的工作区中工作。",
+ "invites": "邀请",
+ "inviteSearch": "邀请时推荐成员",
+ "inviteSearchHint": "团队所有者或管理员在邀请对话框中输入地址时,会按姓名和邮箱列出本实例所有工作区中匹配的账户。关闭后,需要输入完整地址。",
+ "invitesSaved": "邀请设置已保存",
"agents": "代理",
"agentsSaved": "代理设置已保存",
"embedding": "嵌入",
diff --git a/apps/web/messages/zh-TW/god.json b/apps/web/messages/zh-TW/god.json
index ec343adc..84da867f 100644
--- a/apps/web/messages/zh-TW/god.json
+++ b/apps/web/messages/zh-TW/god.json
@@ -179,6 +179,10 @@
"workspaces": "工作區",
"personalWorkspaces": "每人一個工作區",
"personalWorkspacesHint": "每個帳號都會獲得一個以其姓名命名的專屬工作區。關閉後,成員只能在被新增到的工作區中工作。",
+ "invites": "邀請",
+ "inviteSearch": "邀請時推薦成員",
+ "inviteSearchHint": "團隊擁有者或管理員在邀請對話框中輸入地址時,會依姓名和電子郵件列出本執行個體所有工作區中相符的帳號。關閉後,需要輸入完整地址。",
+ "invitesSaved": "邀請設定已儲存",
"agents": "代理",
"agentsSaved": "代理設定已儲存",
"embedding": "嵌入",
diff --git a/apps/web/src/features/god/GodGeneralPage.tsx b/apps/web/src/features/god/GodGeneralPage.tsx
index a6c04959..97172580 100644
--- a/apps/web/src/features/god/GodGeneralPage.tsx
+++ b/apps/web/src/features/god/GodGeneralPage.tsx
@@ -90,6 +90,15 @@ function GeneralForm({
}
}
+ async function setInviteSearch(inviteSearch: boolean) {
+ try {
+ await updateAuth.mutateAsync({ inviteSearch });
+ toast.success(t('invitesSaved'));
+ } catch {
+ // The failure already surfaced through the global mutation error toast.
+ }
+ }
+
async function setAgentSettings(patch: Partial<AgentSettings>) {
try {
await updateAgents.mutateAsync(patch);
@@ -118,6 +127,22 @@ function GeneralForm({
</SettingsCard>
</SettingsSection>
+ <SettingsSection title={t('invites')}>
+ <SettingsCard>
+ <SettingsRow
+ title={t('inviteSearch')}
+ description={t('inviteSearchHint')}
+ control={
+ <Switch
+ checked={auth.inviteSearch}
+ disabled={updateAuth.isPending}
+ onCheckedChange={(checked) => void setInviteSearch(checked)}
+ />
+ }
+ />
+ </SettingsCard>
+ </SettingsSection>
+
<SettingsSection title={t('projectDefaults')}>
<SettingsCard>
<SettingsRow
diff --git a/apps/web/src/features/god/hooks/useGodPolicyForm.test.tsx b/apps/web/src/features/god/hooks/useGodPolicyForm.test.tsx
index 11b6bf6e..5681df40 100644
--- a/apps/web/src/features/god/hooks/useGodPolicyForm.test.tsx
+++ b/apps/web/src/features/god/hooks/useGodPolicyForm.test.tsx
@@ -35,6 +35,7 @@ const settings = {
trustProviderEmails: false,
personalWorkspaces: true,
inviteTtlDays: 7,
+ inviteSearch: false,
allowedEmailDomains: ['company.com'],
hasEmailProvider: true,
hasSsoProvider: true,
diff --git a/apps/web/src/features/god/services/god.service.ts b/apps/web/src/features/god/services/god.service.ts
index abd225f2..b2016354 100644
--- a/apps/web/src/features/god/services/god.service.ts
+++ b/apps/web/src/features/god/services/god.service.ts
@@ -74,7 +74,10 @@ export function useUpdateInstanceAuthSettings() {
const qc = useQueryClient();
return useMutation({
mutationFn: (patch: InstanceAuthSettingsPatch) => updateInstanceAuthSettings(patch),
- onSuccess: (data) => qc.setQueryData(qk.instanceAuthSettings, data),
+ onSuccess: (data) => {
+ qc.setQueryData(qk.instanceAuthSettings, data);
+ qc.setQueryData(qk.inviteSearch, { enabled: data.inviteSearch });
+ },
});
}
diff --git a/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx b/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx
index b3859c98..455a4251 100644
--- a/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx
+++ b/apps/web/src/features/teams/components/members/TeamInviteDialog.tsx
@@ -16,7 +16,8 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
-import { useCreateTeamInvite } from '@/services/teams.service';
+import { useCreateTeamInvite, useInviteSearchQuery } from '@/services/teams.service';
+import TeamInviteSuggestions from './TeamInviteSuggestions';
// The message for each refusal the API can answer with; any other error falls back
// to 'refused'.
@@ -49,6 +50,7 @@ export default function TeamInviteDialog({
const [role, setRole] = useState<InviteTeamRole>('member');
const [refusal, setRefusal] = useState<string | null>(null);
const createInvite = useCreateTeamInvite(teamId);
+ const searchEnabled = useInviteSearchQuery().data?.enabled ?? false;
const ranks: InviteTeamRole[] =
teamRole === 'owner' ? ['member', 'manager', 'owner'] : ['member'];
@@ -98,6 +100,16 @@ export default function TeamInviteDialog({
disabled={createInvite.isPending}
/>
{refusal && <p className="text-xs text-destructive">{refusal}</p>}
+ {searchEnabled && !createInvite.isPending && (
+ <TeamInviteSuggestions
+ teamId={teamId}
+ address={address}
+ onPick={(picked) => {
+ setEmail(picked);
+ setRefusal(null);
+ }}
+ />
+ )}
</div>
<div className="space-y-2">
diff --git a/apps/web/src/features/teams/components/members/TeamInviteSuggestions.test.tsx b/apps/web/src/features/teams/components/members/TeamInviteSuggestions.test.tsx
new file mode 100644
index 00000000..599d921c
--- /dev/null
+++ b/apps/web/src/features/teams/components/members/TeamInviteSuggestions.test.tsx
@@ -0,0 +1,155 @@
+import assert from 'node:assert/strict';
+import { afterEach, beforeEach, describe, it } from 'node:test';
+import { act } from 'react';
+import type { Root } from 'react-dom/client';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { JSDOM } from 'jsdom';
+import type { InviteCandidate } from '@/lib/api/endpoints/invites';
+
+const replacedGlobals = [
+ 'window',
+ 'document',
+ 'navigator',
+ 'Node',
+ 'Element',
+ 'HTMLElement',
+ 'Event',
+ 'MouseEvent',
+ 'KeyboardEvent',
+ 'MutationObserver',
+ 'getComputedStyle',
+ 'requestAnimationFrame',
+ 'cancelAnimationFrame',
+ 'ResizeObserver',
+ 'fetch',
+ 'IS_REACT_ACT_ENVIRONMENT',
+] as const;
+
+const ada: InviteCandidate = {
+ userId: 'u-ada',
+ name: 'Ada Lovelace',
+ email: '[email protected]',
+ image: null,
+};
+
+let dom: JSDOM;
+let root: Root;
+let client: QueryClient;
+let originals: Map<string, PropertyDescriptor | undefined>;
+let searches: string[];
+let picked: string[];
+
+async function settle() {
+ await act(async () => new Promise((resolve) => setTimeout(resolve, 0)));
+}
+
+async function render(address: string) {
+ const { default: TeamInviteSuggestions } = await import('./TeamInviteSuggestions');
+ await act(async () =>
+ root.render(
+ <QueryClientProvider client={client}>
+ <TeamInviteSuggestions
+ teamId={7}
+ address={address}
+ onPick={(email) => picked.push(email)}
+ />
+ </QueryClientProvider>,
+ ),
+ );
+ await settle();
+}
+
+const items = () => [...document.querySelectorAll<HTMLElement>('[data-slot="command-item"]')];
+
+beforeEach(async () => {
+ originals = new Map(
+ replacedGlobals.map((name) => [name, Object.getOwnPropertyDescriptor(globalThis, name)]),
+ );
+ dom = new JSDOM('<!doctype html><div id="root"></div>', {
+ url: 'https://example.test/',
+ pretendToBeVisual: true,
+ });
+ for (const name of replacedGlobals) {
+ if (name in dom.window) {
+ Object.defineProperty(globalThis, name, {
+ configurable: true,
+ value: dom.window[name as keyof typeof dom.window],
+ });
+ }
+ }
+ searches = [];
+ picked = [];
+ Object.defineProperties(globalThis, {
+ getComputedStyle: { configurable: true, value: dom.window.getComputedStyle.bind(dom.window) },
+ requestAnimationFrame: {
+ configurable: true,
+ value: dom.window.requestAnimationFrame.bind(dom.window),
+ },
+ cancelAnimationFrame: {
+ configurable: true,
+ value: dom.window.cancelAnimationFrame.bind(dom.window),
+ },
+ ResizeObserver: {
+ configurable: true,
+ value: class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ },
+ },
+ fetch: {
+ configurable: true,
+ value: async (input: string | URL) => {
+ const url = new URL(String(input));
+ assert.equal(url.pathname, '/teams/7/invites/candidates');
+ searches.push(url.searchParams.get('search') ?? '');
+ return Response.json([ada]);
+ },
+ },
+ IS_REACT_ACT_ENVIRONMENT: { configurable: true, value: true },
+ });
+ Object.defineProperty(window, '__ITSAPLAN_ENV__', {
+ value: { apiUrl: 'https://api.test', privacyUrl: '', termsUrl: '' },
+ });
+ window.HTMLElement.prototype.scrollIntoView = () => {};
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ const { createRoot } = await import('react-dom/client');
+ root = createRoot(document.getElementById('root')!);
+});
+
+afterEach(async () => {
+ await act(async () => root.unmount());
+ client.clear();
+ dom.window.close();
+ for (const [name, descriptor] of originals) {
+ if (descriptor) Object.defineProperty(globalThis, name, descriptor);
+ else Reflect.deleteProperty(globalThis, name);
+ }
+});
+
+describe('TeamInviteSuggestions', () => {
+ it('lists the matches and puts the picked address in the field', async () => {
+ await render('lov');
+
+ assert.deepEqual(searches, ['lov']);
+ assert.equal(items().length, 1);
+ assert.match(items()[0]!.textContent ?? '', /Ada Lovelace.*ada@engine\.test/);
+
+ await act(async () => items()[0]!.click());
+ assert.deepEqual(picked, ['[email protected]']);
+ });
+
+ it('does not search under 2 characters', async () => {
+ await render('a');
+
+ assert.deepEqual(searches, []);
+ assert.equal(items().length, 0);
+ });
+
+ it('hides the list once the field holds a listed address', async () => {
+ await render('[email protected]');
+
+ assert.equal(searches.length, 1);
+ assert.equal(items().length, 0);
+ });
+});
diff --git a/apps/web/src/features/teams/components/members/TeamInviteSuggestions.tsx b/apps/web/src/features/teams/components/members/TeamInviteSuggestions.tsx
new file mode 100644
index 00000000..b9321307
--- /dev/null
+++ b/apps/web/src/features/teams/components/members/TeamInviteSuggestions.tsx
@@ -0,0 +1,46 @@
+'use client';
+
+import { useDebouncedValue } from '@/hooks/useDebouncedValue';
+import { useInviteCandidatesQuery } from '@/services/teams.service';
+import Avatar from '@/components/common/Avatar';
+import { Command, CommandItem, CommandList } from '@/components/ui/command';
+
+export default function TeamInviteSuggestions({
+ teamId,
+ address,
+ onPick,
+}: {
+ teamId: number;
+ address: string;
+ onPick: (email: string) => void;
+}) {
+ const term = useDebouncedValue(address, 300);
+ const candidates = useInviteCandidatesQuery(teamId, term).data ?? [];
+ const typedOne = candidates.some(
+ (person) => person.email.toLowerCase() === address.toLowerCase(),
+ );
+ if (address.length < 2 || candidates.length === 0 || typedOne) return null;
+
+ return (
+ <Command shouldFilter={false} className="h-auto rounded-md border">
+ <CommandList>
+ {candidates.map((person) => {
+ const name = person.name || person.email;
+ return (
+ <CommandItem
+ key={person.userId}
+ value={person.userId}
+ onSelect={() => onPick(person.email)}
+ >
+ <Avatar name={name} image={person.image} className="size-6 text-[10px]" />
+ <div className="min-w-0 flex-1">
+ <p className="truncate">{name}</p>
+ <p className="truncate text-xs text-muted-foreground">{person.email}</p>
+ </div>
+ </CommandItem>
+ );
+ })}
+ </CommandList>
+ </Command>
+ );
+}
diff --git a/apps/web/src/lib/api/endpoints/god.ts b/apps/web/src/lib/api/endpoints/god.ts
index 84065294..c05370fc 100644
--- a/apps/web/src/lib/api/endpoints/god.ts
+++ b/apps/web/src/lib/api/endpoints/god.ts
@@ -25,6 +25,7 @@ export interface InstanceAuthSettings {
personalWorkspaces: boolean;
// Days an invite link stays valid; 0 means invites never expire.
inviteTtlDays: number;
+ inviteSearch: boolean;
// The domains a new account's address must be at; empty admits any address.
allowedEmailDomains: string[];
hasEmailProvider: boolean;
@@ -41,6 +42,7 @@ export interface InstanceAuthSettingsPatch {
trustProviderEmails?: boolean;
personalWorkspaces?: boolean;
inviteTtlDays?: number;
+ inviteSearch?: boolean;
allowedEmailDomains?: string[];
}
diff --git a/apps/web/src/lib/api/endpoints/invites.ts b/apps/web/src/lib/api/endpoints/invites.ts
index d291556a..ce9aeabe 100644
--- a/apps/web/src/lib/api/endpoints/invites.ts
+++ b/apps/web/src/lib/api/endpoints/invites.ts
@@ -108,6 +108,20 @@ export const deleteInvite = (projectKey: string, inviteId: number) =>
export const listTeamInvites = (teamId: number) => request<InviteRow[]>(`/teams/${teamId}/invites`);
+// Someone an invite into the team can be addressed to: an account of the instance
+// outside the team.
+export interface InviteCandidate {
+ userId: string;
+ name: string;
+ email: string;
+ image: string | null;
+}
+
+export const listInviteCandidates = (teamId: number, search: string) =>
+ request<InviteCandidate[]>(
+ `/teams/${teamId}/invites/candidates?${new URLSearchParams({ search })}`,
+ );
+
export const createTeamInvite = (teamId: number, input: { email: string; role: InviteTeamRole }) =>
request<InviteCreateResult>(`/teams/${teamId}/invites`, {
method: 'POST',
diff --git a/apps/web/src/lib/api/endpoints/settings.ts b/apps/web/src/lib/api/endpoints/settings.ts
index 2d95b801..c1a27b37 100644
--- a/apps/web/src/lib/api/endpoints/settings.ts
+++ b/apps/web/src/lib/api/endpoints/settings.ts
@@ -131,6 +131,10 @@ export const getStorageSettings = () => request<StorageSettings>('/settings/stor
// client applies them); the write is god mode.
export const getHotkeySettings = () => request<HotkeyOverrides>('/settings/hotkeys');
+// Whether a team's invite dialog may look up accounts by name or address. The read is
+// open to any signed-in user; the write is god mode.
+export const getInviteSearch = () => request<{ enabled: boolean }>('/settings/invite-search');
+
// The instance's own sign-in policy, readable without a session: the sign-up
// screen needs it before an account exists.
export const getAuthConfig = () => request<PublicAuthConfig>('/auth-config');
diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.ts
index 6693483f..f82af3ac 100644
--- a/apps/web/src/services/queryKeys.ts
+++ b/apps/web/src/services/queryKeys.ts
@@ -167,6 +167,9 @@ export const qk = {
// The invites of a team, including the ones into its projects.
teamInvites: (teamId: number) => ['teamInvites', teamId] as const,
anyTeamInvites: ['teamInvites'] as const,
+ inviteCandidates: (teamId: number, search: string) =>
+ ['teamInvites', teamId, 'candidates', search] as const,
+ inviteSearch: ['inviteSearch'] as const,
// The roles a team offers, which is what every project of it assigns from. The
// permission catalog is app-static, so it is scoped to no team.
teamRoles: (teamId: number, params: unknown) => ['teamRoles', teamId, params] as const,
diff --git a/apps/web/src/services/teams.service.ts b/apps/web/src/services/teams.service.ts
index c207104b..994c16ea 100644
--- a/apps/web/src/services/teams.service.ts
+++ b/apps/web/src/services/teams.service.ts
@@ -10,12 +10,14 @@ import { useTranslations } from 'next-intl';
import {
type InviteTeamRole,
listTeamInvites,
+ listInviteCandidates,
createTeamInvite,
renewTeamInvite,
sendTeamInviteEmail,
deleteTeamInvite,
} from '@/lib/api/endpoints/invites';
import type { MemberKind, MemberListParams } from '@/lib/api/endpoints/members';
+import { getInviteSearch } from '@/lib/api/endpoints/settings';
import {
type TeamProjectListParams,
type Team,
@@ -257,6 +259,20 @@ export function useTeamInvitesQuery(teamId: number, enabled = true) {
});
}
+export function useInviteSearchQuery() {
+ return useQuery({ queryKey: qk.inviteSearch, queryFn: () => getInviteSearch() });
+}
+
+// The API answers only a search of at least 2 characters.
+export function useInviteCandidatesQuery(teamId: number, search: string) {
+ return useQuery({
+ queryKey: qk.inviteCandidates(teamId, search),
+ queryFn: () => listInviteCandidates(teamId, search),
+ enabled: search.length >= 2,
+ placeholderData: keepPreviousData,
+ });
+}
+
// The invite dialog shows the reason under its address field, so this mutation opts
// out of the global error toast.
export function useCreateTeamInvite(teamId: number) {
diff --git a/packages/auth/AGENTS.md b/packages/auth/AGENTS.md
index 7c38d04e..3a86fa21 100644
--- a/packages/auth/AGENTS.md
+++ b/packages/auth/AGENTS.md
@@ -33,7 +33,7 @@ workspace settings can change them without a restart. Read them
through this module — never inline a query on `app_setting` / `app_secret` elsewhere.
- `app_setting` key `auth` → `{ registration, requireEmailVerification, magicLink,
- emailPassword, trustProviderEmails, personalWorkspaces, inviteTtlDays,
+ emailPassword, trustProviderEmails, personalWorkspaces, inviteTtlDays, inviteSearch,
allowedEmailDomains }`.
- `app_secret` keys `auth.email`, `auth.google`, `auth.oidc` and `auth.scim` → the mail
provider, Google, the OIDC provider and the instance's SCIM token, set in god mode;
diff --git a/packages/auth/src/instance.ts b/packages/auth/src/instance.ts
index 8e609020..7ef068bf 100644
--- a/packages/auth/src/instance.ts
+++ b/packages/auth/src/instance.ts
@@ -70,6 +70,9 @@ export interface AuthSettings {
// pending invite older than this neither gates registration nor can be accepted.
// 0 disables the limit (invites never expire).
inviteTtlDays: number;
+ // Let whoever may invite to a team find accounts of the instance by name or address.
+ // Off by default: the search reaches accounts in every workspace.
+ inviteSearch: boolean;
// The domains a new account's address must be at, lowercase. Empty admits any address.
// Accounts that already exist keep signing in.
allowedEmailDomains: string[];
@@ -84,6 +87,7 @@ function defaultAuthSettings(): AuthSettings {
trustProviderEmails: false,
personalWorkspaces: true,
inviteTtlDays: 7,
+ inviteSearch: false,
allowedEmailDomains: [],
};
}