Skip to content

Available user types filtered based on user role - #62

Merged
llam36 merged 4 commits into
mainfrom
davidgu/bug_adminNotSuperadmin
Apr 3, 2026
Merged

Available user types filtered based on user role#62
llam36 merged 4 commits into
mainfrom
davidgu/bug_adminNotSuperadmin

Conversation

@shaply

@shaply shaply commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Although we block it on the backend, the UI for an Admin when they navigate to a per-project user page has the illusion of being able to set SUPERADMIN permissions:

Image

Reproduction Steps

  1. Sign into an ADMIN type (if you don't have one, create a new user using the superadmin credentials)
  2. Navigate to a per-project page (e.g. http://localhost:3000/projects/0/users) and create a new user (this will be of type USER). This works as expected.
  3. Attempt to edit this new user and set the User Type. ADMIN and SUPERADMIN should not be options available for this. Currently, this just throws an ambiguous error if you try to do so anyways.

Fix

Remove user types depending on the user type

Added filtering of user types selectable based on user session when editing a user.

@netlify

netlify Bot commented Nov 17, 2025

Copy link
Copy Markdown

Deploy Preview for juno-dashboard ready!

Name Link
🔨 Latest commit c22bc62
🔍 Latest deploy log https://app.netlify.com/projects/juno-dashboard/deploys/691aba0d16fe310008786747
😎 Deploy Preview https://deploy-preview-62--juno-dashboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@greptile-apps

greptile-apps Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Disclaimer: This comment was AI-generated and is not necessarily completely accurate. Please take code comments with a grain of salt.

Greptile Summary

  • Filters available user types in edit form dropdown based on current user's role (SUPERADMIN can assign all types, ADMIN can only assign USER)
  • Uses useMemo hook to compute available user types and integrates with SessionProvider for current user context

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation correctly filters user types based on role permissions and aligns with backend security, though there's a minor UX consideration when ADMINs view higher-privileged users
  • No files require special attention

Important Files Changed

Filename Overview
src/components/forms/EditUserForm.tsx Filtered user type dropdown based on current user's role - SUPERADMIN sees all types, ADMIN sees only USER

Sequence Diagram

sequenceDiagram
    participant "User" as User
    participant "EditUserForm" as Form
    participant "SessionProvider" as Session
    participant "Backend API" as API
    
    User->>Form: "Open edit user dialog"
    Form->>Session: "Get current user session"
    Session-->>Form: "Return user type (SUPERADMIN/ADMIN/USER)"
    Form->>Form: "Filter available user types based on current user role"
    Form->>User: "Display form with filtered user type dropdown"
    User->>Form: "Select user type and submit"
    Form->>API: "Call setUserTypeAction with selected type"
    API-->>Form: "Return success/error"
    Form->>User: "Show toast notification"
Loading

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

@netlify

netlify Bot commented Feb 20, 2026

Copy link
Copy Markdown

Deploy Preview for juno-dashboard failed. Why did it fail? →

Name Link
🔨 Latest commit 90fbb7b
🔍 Latest deploy log https://app.netlify.com/projects/juno-dashboard/deploys/6997e8ba77da0d00089a4e6e

@netlify

netlify Bot commented Apr 3, 2026

Copy link
Copy Markdown

Deploy Preview for juno-dashboard ready!

Name Link
🔨 Latest commit cf3c706
🔍 Latest deploy log https://app.netlify.com/projects/juno-dashboard/deploys/69cf1361d10769000820e07b
😎 Deploy Preview https://deploy-preview-62--juno-dashboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@llam36 llam36 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@llam36
llam36 merged commit 4652c7e into main Apr 3, 2026
5 checks passed
shaply added a commit that referenced this pull request Apr 5, 2026
* Available user types filtered based on user role

* Forgot to do linting

* fix: format

---------

Co-authored-by: Long Lam <llam36@gatech.edu>
Co-authored-by: Long Lam <lamhoanglong.3001@gmail.com>
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.

[Fall 2025] Admin (not superadmin) should not have the ability to assign SUPERADMIN

2 participants