diff --git a/apps/web/app/(app)/actions.ts b/apps/web/app/(app)/actions.ts index bb13aee6..379dc093 100644 --- a/apps/web/app/(app)/actions.ts +++ b/apps/web/app/(app)/actions.ts @@ -810,7 +810,7 @@ export async function finishOwnClaudeLoginAction(f: FormData) { const user = asWebActor(await requireUser()); await attempt(f, async () => { const p = await projectForUser(db, user.id, Number(str(f, "projectId"))); - await finishOwnClaudeLogin(db, user, p, Number(str(f, "subscriptionId")), str(f, "code")); + await finishOwnClaudeLogin(db, user, p, Number(str(f, "subscriptionId")), str(f, "code"), str(f, "account")); }); } diff --git a/apps/web/app/(app)/subscriptions/actions.ts b/apps/web/app/(app)/subscriptions/actions.ts index 975ce5db..1b94c085 100644 --- a/apps/web/app/(app)/subscriptions/actions.ts +++ b/apps/web/app/(app)/subscriptions/actions.ts @@ -1,7 +1,7 @@ "use server"; // «Подписки» (PEP-67): every action is superadmin-only (others get "not found"). -import { createPool, deletePool, getProject, lendSubscription, PeppaError, returnLoanNow, requireSuperadmin, setProjectPool, updatePool, updateSubscription, type SubscriptionProvider } from "@peppa/core"; +import { createPool, deletePool, getProject, lendSubscription, PeppaError, returnLoanNow, requireSuperadmin, setProjectPool, updatePool, updateSubscription, type SubscriptionProvider, setSubscriptionAccount } from "@peppa/core"; import { addPoolSubscription, addSubscription, switchAgents, cancelLogin, checkSubscription, finishClaudeLogin, removeSubscription, startClaudeLogin, startCodexLogin } from "@peppa/runner"; import { revalidatePath } from "next/cache"; import { redirect } from "next/navigation"; @@ -82,7 +82,7 @@ export async function reconnectSubscription(f: FormData) { export async function submitLoginCode(f: FormData) { await attempt(f, async () => { const id = Number(str(f, "id")); - await finishClaudeLogin(db, id, str(f, "code")); + await finishClaudeLogin(db, id, str(f, "code"), str(f, "account")); return `${BASE}?added=${id}#s-${id}`; }); } @@ -105,6 +105,8 @@ export async function renameSubscription(f: FormData) { await attempt(f, async () => { if (!str(f, "name")) throw new PeppaError(m("Нужно название подписки")); await updateSubscription(db, Number(str(f, "id")), { name: str(f, "name") }); + // PEP-178: which account it is — the e-mail the person signed in with. + if (f.has("account")) await setSubscriptionAccount(db, Number(str(f, "id")), str(f, "account")); }); } diff --git a/apps/web/app/(app)/subscriptions/page.tsx b/apps/web/app/(app)/subscriptions/page.tsx index 8db4c00c..8752ab07 100644 --- a/apps/web/app/(app)/subscriptions/page.tsx +++ b/apps/web/app/(app)/subscriptions/page.tsx @@ -1,7 +1,7 @@ import { notFound } from "next/navigation"; import { ExternalLink, KeyRound, Plus, RefreshCw } from "lucide-react"; import { isSuperadmin, listSubscriptions, OPENCODE_KEY_ENV, PROVIDER_NAMES, poolOverviews, type PoolOverview, type SubscriptionView } from "@peppa/core"; -import { pendingLogin, pollCodexLogin, type PendingLogin } from "@peppa/runner"; +import { pendingLogin, pollCodexLogin, type PendingLogin, backfillCodexAccounts } from "@peppa/runner"; import { AutoRefresh } from "@/components/AutoRefresh"; import { PoolSubscriptions, PoolSummary, PoolSwitches } from "@/components/PoolSubscriptions"; import { Hidden } from "@/components/cards"; @@ -27,6 +27,7 @@ import { returnLoanAction, reconnectSubscription, submitLoginCode, + renameSubscription, updatePoolAction, } from "./actions"; @@ -54,6 +55,7 @@ function LoginSteps({ s, login, t }: { s: SubscriptionView; login: PendingLogin;
> @@ -100,6 +102,7 @@ function Problem({ s, login, t }: { s: SubscriptionView; login: PendingLogin | n