diff options
| author | Frank <[email protected]> | 2025-10-04 01:12:22 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-10-04 01:12:32 -0400 |
| commit | 82509e86041a5d1a00da47c20d4e28fb07a84e99 (patch) | |
| tree | f886dd4504f4ddc71e1a2d5f9c58e873de3cc0c9 /packages/console/core/src/user.ts | |
| parent | e7b6ffb31484c7bcc809aebbdcaf7d2ce49a13d5 (diff) | |
| download | opencode-82509e86041a5d1a00da47c20d4e28fb07a84e99.tar.gz opencode-82509e86041a5d1a00da47c20d4e28fb07a84e99.zip | |
wip: zen
Diffstat (limited to 'packages/console/core/src/user.ts')
| -rw-r--r-- | packages/console/core/src/user.ts | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/packages/console/core/src/user.ts b/packages/console/core/src/user.ts index f6a78ad48..c9567a2cb 100644 --- a/packages/console/core/src/user.ts +++ b/packages/console/core/src/user.ts @@ -100,12 +100,25 @@ export namespace User { ) // create api key - //if (account) { - // const existing = await Database.use(tx => { - // const key = tx.select().from(KeyTable).where(and(eq(KeyTable.workspaceID, workspaceID), eq(KeyTable, account.id))).then((rows) => rows[0]) - // return key - // }) - //} + if (account) { + await Database.use(async (tx) => { + const user = await tx + .select() + .from(UserTable) + .where(and(eq(UserTable.workspaceID, workspaceID), eq(UserTable.accountID, account.id))) + .then((rows) => rows[0]) + + const key = await tx + .select() + .from(KeyTable) + .where(and(eq(KeyTable.workspaceID, workspaceID), eq(KeyTable.userID, user.id))) + .then((rows) => rows[0]) + + if (key) return + + await Key.create({ userID: user.id, name: "Default API Key" }) + }) + } // send email, ignore errors try { @@ -151,12 +164,11 @@ export namespace User { await Promise.all( invitations.map((invite) => Actor.provide( - "user", + "system", { workspaceID: invite.workspaceID, - userID: invite.id, }, - () => Key.create({ name: "Default API Key" }), + () => Key.create({ userID: invite.id, name: "Default API Key" }), ), ), ) |
