Skip to content

Feat: add api token support#2216

Open
wreality wants to merge 5 commits intomasterfrom
feature/sanctum-tokens
Open

Feat: add api token support#2216
wreality wants to merge 5 commits intomasterfrom
feature/sanctum-tokens

Conversation

@wreality
Copy link
Copy Markdown
Contributor

@wreality wreality commented Feb 5, 2026

This pull request implements support for personal access tokens (API tokens) in both the backend and frontend. It introduces GraphQL queries and mutations for creating, listing, and revoking tokens, adds the necessary database migrations, and provides a user interface for managing tokens in the account section. Comprehensive backend and frontend tests are included to ensure correct functionality and access control.

Backend: Personal Access Token API and Storage

  • Added GraphQL mutations and queries for creating, listing, and revoking personal access tokens for the authenticated user (PersonalAccessToken.php, PersonalAccessTokens.php, personal_access_token.graphql). [1] [2] [3]
  • Added database migrations to create the personal_access_tokens table and support an optional expires_at column (2019_12_14_000001_create_personal_access_tokens_table.php, 2026_02_05_144709_add_expires_at_to_personal_access_tokens_table.php). [1] [2]
  • Added extensive backend tests covering authentication, token creation, listing, revocation, and access control (PersonalAccessTokenTest.php).

Frontend: Token Management UI

  • Added new tokens management page to the account section, including navigation, UI components for creating and revoking tokens, and integration with the backend API (TokensPage.vue, CreateTokenDialog.vue, AccountLayout.vue). [1] [2]
  • Added GraphQL queries and mutations for token management to the frontend (queries.js, mutations.js). [1] [2]
  • Added English i18n strings for all token-related UI labels and messages (en-US.json).
  • Added frontend unit tests for the tokens page, covering rendering, empty state, and UI actions (TokensPage.vitest.spec.js).

Schema Integration

  • Integrated the new personal access token schema into the main GraphQL schema (schema.graphql).

@wreality wreality force-pushed the feature/sanctum-tokens branch 2 times, most recently from e70c2d5 to 851f039 Compare February 19, 2026 15:00
- Add personalAccessTokens query to list user's tokens
- Add createPersonalAccessToken mutation to create new tokens
- Add revokePersonalAccessToken mutation to delete tokens
- Publish Sanctum migration for personal_access_tokens table
- Add migration for expires_at column (Sanctum 4.x)
- Add comprehensive test coverage (10 tests)
- Add TokensPage under Account section with list/create/revoke
- Add CreateTokenDialog with random default name placeholder
- Add GraphQL queries and mutations for token operations
- Add route /account/tokens and sidebar navigation link
- Add i18n translations for all token UI strings
- Add Vitest unit tests for TokensPage (7 tests)
Restructure the GraphQL API to access personal access tokens via
currentUser.tokens instead of a separate personalAccessTokens root query.
This provides a more intuitive API design where tokens are accessed as
a property of the authenticated user.

- Add tokens field to User type using @morphMany directive
- Remove personalAccessTokens root query and its resolver
- Update frontend query and component to use new path
- Update all backend and frontend tests
- Remove blank lines before declare(strict_types=1)
- Remove unused import alias
- Use fully qualified class name in docblock
- Remove spaces after cast statements
@wreality wreality force-pushed the feature/sanctum-tokens branch from 851f039 to 024dbb2 Compare February 26, 2026 04:11
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