Skip to content

Admins can star any project, and admin rights reach the client live - #8

Merged
andreasnanko merged 1 commit into
mainfrom
fix/admin-session-star
Nov 19, 2026
Merged

andreasnanko merged 1 commit into
mainfrom
fix/admin-session-star

Conversation

@andreasnanko

Copy link
Copy Markdown
Contributor

What

Two ways an instance admin was treated as a regular user in the browser.

Admin rights granted after sign-in did not reach the client. isAdmin is written into the sealed session cookie at sign-in and the client reads only that copy (useUserSession), while the server reads it fresh in requireActiveSession. An admin made after signing in saw no admin menu and no "Add people" in projects they were not a member of, until they signed in again; a demoted admin kept the controls the server then refused. server/plugins/session-capabilities.ts already refreshed canManageAgents on every /api/_auth/session fetch for this reason; it now sets isAdmin from the database too. Every client check (auth.global for /admin, admin menu, ProjectMembers, useKanban, useViewData, agents) reads that field. Reported as CF-1322.

Admins could not star a project they are not a member of (PUT /api/projects/:id/star answered 403, and both star buttons were hidden for role: 'admin'). Starring is now open to everyone who can see the project. The star is still re-checked on every read, against membership or admin rights, so leaving a project or losing admin drops it without touching project_stars.

Changed: session hook, star.put.ts, starred in projects/index.get.ts and projects/[id].get.ts, the star buttons on All Projects and the project page, schema comment, OpenAPI, CHANGELOG.

Tests

  • pnpm lint, pnpm typecheck, pnpm test: 133 files, 2021 passed, 8 skipped.
  • New auth/session-admin.test.ts: /api/_auth/session follows a promotion and a demotion without a new sign-in.
  • projects/star.test.ts: the 403 test is replaced by "an admin who is not a member can star and unstar", plus "an admin keeps the star after leaving the project" and "a star stops counting once its owner can no longer see the project" (removed and demoted).

🤖 Generated with Claude Code

The session fetch hook now sets isAdmin from the database next to
canManageAgents. The client read it only from the sealed cookie, so an
admin granted after sign-in saw no admin menu and no "Add people" in
projects they were not in until they signed in again, while the server
already allowed it; a demoted admin kept the controls.

Starring was refused (403) for an admin who is not a member. It is now
open to everyone who can see the project. A star still counts only while
the caller is a member or an admin, so a removal or a demotion drops it
without touching project_stars.
@andreasnanko
andreasnanko merged commit 7d61de8 into main Nov 19, 2026
4 checks passed
@andreasnanko
andreasnanko deleted the fix/admin-session-star branch November 19, 2026 09:04
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.

1 participant