Add useApiTokens hook and refactor token UI

Introduce a shared useApiTokens hook to centralize API token CRUD and UI state (fetch, create, delete, copy, formatting). Refactor ApiTab and ApiTokensSection to consume the hook and remove duplicated logic. Add getInstanceUrl utility for client origin used in curl examples. Include an id alias in TokenPayload and add id into generated JWTs across auth routes and providers; update tests accordingly. Improve auth middleware typing and add debug logging around lastUsedAt updates. Add admin logging when creating a token with a role that differs from the target user's role.
This commit is contained in:
kikootwo
2026-03-04 15:18:48 -05:00
parent d6eca611fc
commit a50fbc721e
17 changed files with 344 additions and 311 deletions
+2
View File
@@ -17,6 +17,7 @@ describe('JWT utilities', () => {
it('generates and verifies access tokens', () => {
const token = generateAccessToken({
sub: 'user-1',
id: 'user-1',
plexId: 'plex-1',
username: 'user',
role: 'admin',
@@ -57,6 +58,7 @@ describe('JWT utilities', () => {
it('decodes tokens without verification', () => {
const token = generateAccessToken({
sub: 'user-4',
id: 'user-4',
plexId: 'plex-4',
username: 'user',
role: 'user',