Repository navigation
Team member management, last login, build trigger and report theme toggle - #140
Merged
Merged
Conversation
…eme toggle - Team leads (and admins) can list, add and remove the members of a team via GET/POST /team/:teamId/members and DELETE /team/:teamId/members/:userId. Session-only (API tokens are rejected). Team leads manage plain users only: they cannot add or remove other team leads or admins, nor remove themselves, so lead access cannot be handed out through membership. - Record User.lastLoginAt on every successful sign-in (local, LDAP, SSO) without touching updatedAt; it is returned by the admin user endpoints. - Record Build.triggeredBy (user, username snapshot and, for API-key requests, the token name) when a build is created. - The HTML build report gets a light/dark toggle (data-theme, remembered in localStorage, OS preference until chosen, light when printing) and a "Triggered by" fact. - Index User.teams; document the new endpoints and fields in swagger. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121r5gnmvth6hy4tPpNT8sM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Back-end for four related features. UI, JS client and docs PRs are linked below.
GET/POST /team/:teamId/membersandDELETE /team/:teamId/members/:userId. Allowed for admins and the team's own leads. Session-only, API tokens get 403, like the user routes.userrole. They cannot add or remove other team leads or admins, and cannot remove themselves.team_leadmembership is what grants lead powers, so otherwise a lead could hand out lead access to a team. Admins can manage anyone._id,username,roleandauthProvider.User.teamsis now indexed, because the member list is a lookup from the user side.User.lastLoginAtis set on every successful sign-in (local, LDAP, SSO callback) through onecompleteLoginhelper.updatedAtis not touched. A failure to record it is logged and never blocks the login. It is returned by the existing adminGET /users. API-token requests don't count as a login.Build.triggeredBy { user, username, tokenName }is set inPOST /buildfrom the authenticated caller.tokenNameis the API key's name (never the token). The username is copied so history survives account deletion. Builds created before this have no value.data-theme. Until the viewer chooses, it follows the OS (the media query is guarded on the attribute being absent, as in the UI). The choice is remembered inlocalStorageand applied before first paint (the head script carries the report nonce, so the CSP is unchanged). The report prints in light mode. The toggle is hidden when JS is off. The report also gets a "Triggered by" fact.Testing
test/team-members.tests.js(32 tests): permissions and role rules, 403/404/409/422 paths, API-token rejection, last login (set, not set on failure,updatedAtunchanged, visible to admins),triggeredByvia session and API key (including after account deletion), report content.Notes
eslint .still reports pre-existing errors inscripts/andsetup/, none in changed files.🤖 Generated with Claude Code
https://claude.ai/code/session_0121r5gnmvth6hy4tPpNT8sM
Generated by Claude Code