History

Disable invite creation when WorkOS is not enabled

Rhys Sullivan committed 9 months ago

Commit ddca61b1 parent ffb327f1 file · +5 −1Browse files

Unified · Split

executor/convex/invites.ts+5−1
@@ -46,12 +46,16 @@ export const create = organizationMutation({ · 45 unmodified lines
46 expiresInDays: v.optional(v.number()),46 expiresInDays: v.optional(v.number()),
47 },47 },
48 handler: async (ctx, args) => {48 handler: async (ctx, args) => {
49 if (!workosEnabled) {
50 throw new Error("Invites require WorkOS auth to be enabled");
51 }
52
49 const now = Date.now();53 const now = Date.now();
50 const expiresAt = now + (args.expiresInDays ?? 7) * 24 * 60 * 60 * 1000;54 const expiresAt = now + (args.expiresInDays ?? 7) * 24 * 60 * 60 * 1000;
51 55
52 const token = `invite_${crypto.randomUUID()}`;56 const token = `invite_${crypto.randomUUID()}`;
53 const tokenHash = await sha256Hex(token);57 const tokenHash = await sha256Hex(token);
54 const provider = workosEnabled ? "workos" : "local";58 const provider = "workos";
55 59
56 const inviteId = await ctx.db.insert("invites", {60 const inviteId = await ctx.db.insert("invites", {
57 organizationId: ctx.organizationId,61 organizationId: ctx.organizationId,