Skip to content

Commit 1be1095

Browse files
authored
feat: add optional tscircuit_handle parameter to account retrieval (#2011)
1 parent a399875 commit 1be1095

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

fake-snippets-api/routes/api/accounts/get.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default withRouteSpec({
1010
methods: ["GET", "POST"],
1111
auth: "session",
1212
commonParams: z.object({
13+
tscircuit_handle: z.string().optional(),
1314
github_username: z.string().optional(),
1415
}),
1516
jsonResponse: z.object({
@@ -19,8 +20,16 @@ export default withRouteSpec({
1920
}),
2021
})(async (req, ctx) => {
2122
let account: Account | undefined
22-
const { github_username } = req.commonParams
23-
if (github_username) {
23+
const { github_username, tscircuit_handle } = req.commonParams
24+
if (tscircuit_handle) {
25+
const foundAccount = ctx.db.accounts.find(
26+
(acc: Account) =>
27+
acc.tscircuit_handle?.toLowerCase() === tscircuit_handle.toLowerCase(),
28+
)
29+
if (foundAccount) {
30+
account = { ...foundAccount, email: undefined }
31+
}
32+
} else if (github_username) {
2433
const foundAccount = ctx.db.accounts.find(
2534
(acc: Account) =>
2635
acc.github_username?.toLowerCase() === github_username.toLowerCase(),

src/pages/user-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default function UserSettingsPage() {
126126
const userInfo = [
127127
{
128128
label: "GitHub Username",
129-
value: account?.github_username || "Not available",
129+
value: account?.github_username || "Not connected",
130130
},
131131
{
132132
label: "Email",

0 commit comments

Comments
 (0)