Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions components/console/account-page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function formatCreatedAt(createdAt: number): string {
}

export function AccountPageClient({ user, hasGithubConnection }: { user: UserProfile | null; hasGithubConnection: boolean }) {
const [displayName, setDisplayName] = useState(user?.name ?? user?.email?.split("@")[0] ?? "");
const [username, setUsername] = useState(user?.id ?? "");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Don’t initialize editable username from internal user.id.

Using user.id here exposes an internal identifier as a user-editable profile value. Initialize from a dedicated username source (or "") instead.

Suggested change
-  const [username, setUsername] = useState(user?.id ?? "");
+  const [username, setUsername] = useState("");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [username, setUsername] = useState(user?.id ?? "");
const [username, setUsername] = useState("");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/console/account-page-client.tsx` at line 41, The state initializer
currently seeds editable username from the internal identifier (user?.id) which
exposes an internal ID; change the initialization of username in the component
to use a dedicated public field (e.g., user?.username or user?.displayName) or
default to an empty string, and update any places that read/write username
(e.g., setUsername and form submit handlers) to operate on that public username
field instead of user.id so the internal ID is never used as an editable value.

const [showOld, setShowOld] = useState(false);
const [showNew, setShowNew] = useState(false);
const [deleteInput, setDeleteInput] = useState("");
Expand Down Expand Up @@ -96,22 +98,25 @@ export function AccountPageClient({ user, hasGithubConnection }: { user: UserPro

<Field label="Display Name">
<input
value={user?.email?.split("@")[0] ?? ""}
readOnly
value={displayName}
onChange={(e) => setDisplayName(e.target.value)}
placeholder="Enter your display name"
className="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 transition-colors focus:border-gray-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-800 dark:text-white dark:focus:border-zinc-400"
/>
</Field>
<Field label="Email Address">
<input
value={user?.email ?? ""}
placeholder="Email managed by provider"
readOnly
className="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 transition-colors focus:border-gray-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-800 dark:text-white dark:focus:border-zinc-400"
/>
</Field>
<Field label="User ID">
<Field label="Username">
<input
value={user?.id ?? ""}
readOnly
value={username}
onChange={(e) => setUsername(e.target.value)}
placeholder="Enter your username"
className="w-full rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 transition-colors focus:border-gray-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-800 dark:text-white dark:focus:border-zinc-400"
/>
</Field>
Expand Down
1 change: 1 addition & 0 deletions lib/user-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type UserRow = {

export type UserProfile = {
id: string;
name?: string | null;
email: string;
createdAt: number;
};
Expand Down
Loading