Skip to content

feat(user): implement users manager#289

Open
mizhm wants to merge 22 commits intomainfrom
feat/user-management
Open

feat(user): implement users manager#289
mizhm wants to merge 22 commits intomainfrom
feat/user-management

Conversation

@mizhm
Copy link
Contributor

@mizhm mizhm commented Mar 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 2, 2026 01:40
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces robust user management capabilities to the console application, empowering administrators with a dedicated interface to oversee and control user accounts. It includes a new navigation entry, a dynamic user listing page, and a detailed user profile view that facilitates administrative actions like banning and role assignment. The changes also include an improvement to the underlying data table hook for more efficient parameter handling.

Highlights

  • User Management Interface: A new 'Admin' section has been added to the console's sidebar navigation, featuring a 'Users' submenu item. This provides a dedicated entry point for administrative user management.
  • User Listing and Details: New pages and components have been introduced to display a comprehensive list of users in a data table, complete with filtering, sorting, and pagination. Clicking on a user opens a detail sheet where administrators can view user information and perform actions.
  • Administrative Actions: The user detail sheet enables administrators to ban or unban users and change their roles (e.g., to 'admin' or 'user'), with immediate feedback via toast notifications.
  • Enhanced Data Table Hook: The useServerDataTable hook has been refactored to allow setting multiple table parameters (like page, pageSize, sortBy, sortOrder, and filter) simultaneously using a single setParams function, improving flexibility and reducing boilerplate.
  • Auth Client Integration: The better-auth/client/plugins admin client has been integrated into the authClient, and the User type has been extended to include administrative fields such as role, banned, banReason, and banExpires.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • console/src/components/common/layout/menu-bar.tsx
    • Added a new 'Admin' menu item with a 'Users' submenu to the sidebar.
  • console/src/hooks/useServerDataTable.ts
    • Refactored the setParam function to setParams to allow updating multiple data table parameters simultaneously.
    • Updated all table handlers to use the new setParams function for consistency.
  • console/src/pages/admin/list-users.tsx
    • Added a new page component to display a paginated, sortable, and filterable list of users using useServerDataTable.
    • Implemented user data fetching and display, including user status (banned/active) and role badges.
  • console/src/pages/admin/user-detail-sheet.tsx
    • Added a new sheet component to display detailed user information.
    • Implemented functionality to ban/unban users and change user roles via mutations.
    • Displayed user status, role, ban reason, and ban expiration date.
  • console/src/pages/admin/users.tsx
    • Added a new wrapper page component for the user listing.
  • console/src/routers/index.tsx
    • Configured new routes for the /admin/users page.
  • console/src/utils/authClient.ts
    • Integrated the adminClient plugin from better-auth/client/plugins.
    • Extended the User type to include role, banned, banReason, and banExpires properties for administrative purposes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an Admin “Users” management surface to the console using better-auth’s admin client plugin, including routing, navigation, and new pages for listing users and viewing/updating user status.

Changes:

  • Enable better-auth admin plugin in the console auth client and introduce a local User type.
  • Add /admin/users route + sidebar navigation entry, and implement Users page, list view, and detail/action sheet.
  • Refactor useServerDataTable to support setting multiple params at once via setParams.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
console/src/utils/authClient.ts Enables adminClient() plugin and defines an extended User type used by the admin UI.
console/src/routers/index.tsx Registers the new /admin/users route under the authenticated area.
console/src/pages/admin/users.tsx Adds the top-level Admin Users page wrapper.
console/src/pages/admin/list-users.tsx Implements server-driven user listing table and selection to open a detail sheet.
console/src/pages/admin/user-detail-sheet.tsx Implements user detail display and admin actions (ban/unban, role change).
console/src/hooks/useServerDataTable.ts Refactors param updates to a multi-field setParams helper.
console/src/components/common/layout/menu-bar.tsx Adds “Admin → Users” entry to the sidebar navigation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +102
{
path: 'admin',
children: [
{
path: 'users',
element: <Users />,
},
],
},
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The new /admin/users route is only protected by ProtectedRoute (authentication) and does not enforce an admin role. As a result, any logged-in user can reach the admin UI and trigger admin API calls. Consider adding an explicit role-based guard for the admin route subtree (redirect/403) rather than relying on API failures.

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +62
{
title: 'Admin',
url: '#',
items: [
{
title: 'Users',
icon: <User />,
url: '/admin/users',
},
],
},
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The sidebar always shows the new "Admin → Users" navigation item without checking the current user's role. This exposes admin functionality to non-admin users (leading to confusing UX at best, and unnecessary surface area). Consider conditionally rendering this section based on the session user's role or a dedicated permissions check.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a user management feature, including a user list page and a user detail view with admin actions, along with new routes and components. A critical security vulnerability has been identified: the new 'Admin' menu section and the /admin/users route lack proper role-based access control (RBAC) on the frontend, making them accessible to any authenticated user and exposing sensitive data. Additionally, the review highlighted areas for improvement in the new components, including suboptimal initial loading state handling in list-users.tsx, incomplete query invalidation in user-detail-sheet.tsx which could lead to stale data, and a minor issue with accessing a user's name for the avatar fallback.

Comment on lines +95 to +102
path: 'admin',
children: [
{
path: 'users',
element: <Users />,
},
],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

security-high high

The '/admin/users' route is protected only by 'ProtectedRoute', which typically only verifies authentication. There is no check for the 'admin' role, allowing any logged-in user to navigate to the user management page. This could lead to the exposure of sensitive user information (PII) and administrative actions to unauthorized users. Access to the '/admin' route and its children should be restricted to users with the 'admin' role, for example by using a specialized 'AdminRoute' component or by passing role requirements to the 'ProtectedRoute'.

Comment on lines +53 to +62
title: 'Admin',
url: '#',
items: [
{
title: 'Users',
icon: <User />,
url: '/admin/users',
},
],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The 'Admin' menu section is rendered for all authenticated users without checking if they have the 'admin' role. This exposes administrative functionality in the UI to unauthorized users. While backend enforcement may prevent unauthorized actions, exposing these menu items to non-admin users violates the principle of least privilege and increases the attack surface. It is recommended to conditionally render this section only for users with administrative privileges by checking the user's role from the session.

},
onSuccess: () => {
toast.success(`User has been ${aUser?.banned ? 'unbanned' : 'banned'}.`);
return queryClient.invalidateQueries({ queryKey: ['user', aUser?.id] });
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

After successfully updating a user's status (ban/unban), the list of users on the main page should be updated to reflect this change. Currently, only the specific user query (['user', aUser?.id]) is invalidated. You should also invalidate the users list query to ensure the UI is consistent.

      queryClient.invalidateQueries({ queryKey: ['users'] });
      return queryClient.invalidateQueries({ queryKey: ['user', aUser?.id] });

},
onSuccess: () => {
toast.success('User role updated.');
return queryClient.invalidateQueries({ queryKey: ['user', aUser?.id] });
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

After successfully updating a user's role, the list of users on the main page should be updated to reflect this change. Currently, only the specific user query (['user', aUser?.id]) is invalidated. You should also invalidate the users list query to ensure the UI is consistent.

      queryClient.invalidateQueries({ queryKey: ['users'] });
      return queryClient.invalidateQueries({ queryKey: ['user', aUser?.id] });

alt={aUser.name}
/>
<AvatarFallback className="text-3xl">
{aUser.name[0]}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Accessing aUser.name[0] might be unsafe if aUser.name is an empty string. While React can render undefined without crashing, it's better to handle this case explicitly to avoid unexpected behavior in the UI and provide a fallback. Using optional chaining ?. and a fallback character is a safer approach.

                    {aUser.name?.[0] || '?'}

@l1ttps l1ttps changed the title Feat/user management feat(user): implement users manager Mar 7, 2026
mizhm and others added 9 commits March 7, 2026 16:12
* feat(asset): add tls filter for asset

* fix(core): fix asset test

* fix(asset): fix based on bot reviews

* fix(console): fix small typo in tls tab

* fix(console): add missing tls for queryParams in asset context

* fix(console): fix tls query hook in dashboard

---------

Co-authored-by: Quang Vinh <32523515+l1ttps@users.noreply.github.com>
Bumps [multer](https://github.com/expressjs/multer) from 2.0.2 to 2.1.0.
- [Release notes](https://github.com/expressjs/multer/releases)
- [Changelog](https://github.com/expressjs/multer/blob/main/CHANGELOG.md)
- [Commits](expressjs/multer@v2.0.2...v2.1.0)

---
updated-dependencies:
- dependency-name: multer
  dependency-version: 2.1.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* refactor(targets): combine logic create target in transaction

* feat(targets): add bulk target creation endpoint

* feat(targets): add bulk creation support
Co-authored-by: Quang Vinh <32523515+l1ttps@users.noreply.github.com>
…nd re-design settings ui (#299)

* feat(console): add all workspaces navigation and improve 404 page UI

* refactor(layout): extract header into dedicated HeaderBar component

* refactor(console): add workspace-aware header layout

* refactor(console): convert workspace creation to page and add route protection

* refactor(console): update workspaces UI from table to card layout

* feat(workspaces): add member and target counts to workspace list

* refactor(settings): reorganize settings page with sidebar layout

* feat(settings): add API keys management

* refactor(settings): improve API key display layout

* fix(screenshot-cell): add type assertion for screenshotPath

* refactor(workspaces): use workspace selector hook
LayoutDashboard,
SquareTerminal,
Target,
User,
Copy link

Choose a reason for hiding this comment

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

WARNING: Imported User icon but admin route lacks proper protection

The Admin section with Users route is added to the sidebar menu, but there's no indication that this route is protected by authentication or authorization middleware. Anyone could potentially access /admin/users without proper credentials.

@@ -48,6 +49,17 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
},
Copy link

Choose a reason for hiding this comment

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

CRITICAL: Admin section route /admin/users missing authentication protection

The new Admin > Users menu item links to /admin/users but there's no evidence this route is protected by authentication middleware. This could allow unauthenticated access to user management functionality.

@@ -48,6 +49,17 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
},
],
Copy link

Choose a reason for hiding this comment

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

CRITICAL: Admin section route /admin/users missing authorization check

Even if authenticated, there's no indication that only admin users can access the /admin/users route. Regular users could potentially access user management functionality.

@@ -48,6 +49,17 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
},
],
},
Copy link

Choose a reason for hiding this comment

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

WARNING: Admin section route /admin/users missing role-based validation

The route should validate that the user has the appropriate role (admin) before granting access to user management features.

},
],
},
{
Copy link

Choose a reason for hiding this comment

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

WARNING: Admin section route /admin/users missing permission check

Beyond role validation, there should be specific permission checks for user management actions (view, create, edit, delete users).

[setParams],
),
setFilter: useCallback(
(v: string) => {
Copy link

Choose a reason for hiding this comment

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

SUGGESTION: setFilter should implement debouncing

For search/filter functionality, consider adding debounce to prevent excessive API calls while user is typing.

setParam('filter', v);
}
if (filter === v) return;
setParams({
Copy link

Choose a reason for hiding this comment

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

SUGGESTION: Consider resetting page on filter change

When filter changes, it's common practice to reset to page 1 since the filtered results may have different pagination. This is already implemented, which is good.

const formSchema = z.object({
name: z.string().min(1, 'Name is required'),
email: z.string().min(1, 'Email is required').email('Invalid email address'),
password: z.string().min(8, 'Password must be at least 8 characters'),
Copy link

Choose a reason for hiding this comment

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

SUGGESTION: Add password confirmation field for better UX and security

The password field lacks a confirmation field which is standard practice for user creation to prevent typos. Consider adding a 'confirmPassword' field with validation that it matches the password field.

<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input
Copy link

Choose a reason for hiding this comment

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

SUGGESTION: Consider showing password strength indicator

For better user experience, consider adding a password strength indicator to help users create stronger passwords.

<FormControl>
<Input
type="password"
placeholder="Min. 8 characters"
Copy link

Choose a reason for hiding this comment

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

SUGGESTION: Add 'show password' toggle for accessibility

Consider adding a toggle to show/hide the password field content for better accessibility and user experience.

@kilo-code-bot
Copy link

kilo-code-bot bot commented Mar 14, 2026

Code Review Summary

Status: 15 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 2
WARNING 5
SUGGESTION 8
Issue Details (click to expand)

CRITICAL

File Line Issue
console/src/components/common/layout/menu-bar.tsx 49 Admin section route /admin/users missing authentication protection
console/src/components/common/layout/menu-bar.tsx 50 Admin section route /admin/users missing authorization check

WARNING

File Line Issue
console/src/components/common/layout/menu-bar.tsx 31 Imported User icon but admin route lacks proper protection
console/src/components/common/layout/menu-bar.tsx 51 Admin section route /admin/users missing role-based validation
console/src/components/common/layout/menu-bar.tsx 52 Admin section route /admin/users missing permission check
console/src/hooks/useServerDataTable.ts 61 setParams function signature change may break existing consumers
console/src/hooks/useServerDataTable.ts 64 setParams implementation may cause infinite loops

SUGGESTION

File Line Issue
console/src/hooks/useServerDataTable.ts 68 Consider adding validation for parameter values
console/src/hooks/useServerDataTable.ts 76 Add error handling for URL parameter updates
console/src/hooks/useServerDataTable.ts 80 Consider preserving unspecificed parameters when using internal state
console/src/hooks/useServerDataTable.ts 100 setPage handler should preserve other table state
console/src/hooks/useServerDataTable.ts 102 setPageSize reset to page 1 may be unexpected
console/src/hooks/useServerDataTable.ts 106 setSortBy should validate input
console/src/hooks/useServerDataTable.ts 110 setSortOrder should validate input
console/src/hooks/useServerDataTable.ts 114 setFilter should implement debouncing
console/src/pages/admin/add-user-dialog.tsx 39 Add password confirmation field for better UX and security
Other Observations (not in diff)
File Line Issue
console/src/utils/authClient.ts 16 New User type requires validation in existing code
Files Reviewed (12 files)
  • console/src/components/common/layout/menu-bar.tsx - 5 issues
  • console/src/hooks/useServerDataTable.ts - 8 issues
  • console/src/pages/admin/add-user-dialog.tsx - 1 issue
  • console/src/routers/index.tsx - 1 issue

Fix these issues in Kilo Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants