Skip to content

Credentials in AuthControls are not synchronized across instances and do not persist on keypress #46

Description

@gitmibrahim

Describe the bug

When using useAuthState in multiple components across the page (e.g., in a header Auth Control and inside an Endpoint Try Panel), the credentials do not update reactively when changed in one of the components. The state is only synchronized when page reloads because useAuthState reads from sessionStorage in onMounted.
Additionally, typing a credential in the AuthControls input field does not persist until the field loses focus (blur) or the user presses Enter, which causes input values to be lost if a request is immediately sent or if the panel is closed/switched.

Steps to reproduce

  1. Configure openApiDocs with a spec that uses a security scheme (e.g., bearer token).
  2. Add multiple OpenApiEndpoint components or mount multiple components that use useAuthState with the same specName.
  3. Type a token in the authorization input field of one component.
  4. Note that the credential is not immediately saved on keypress, and notice that other components referencing the same specName auth state do not update reactively.

Expected behavior

  • Credentials typed in the input field should be committed immediately on input.
  • Multiple active hook instances of useAuthState should share the same underlying reactive ref cache in memory, so changes to authorization state propagate immediately across all components referencing the same spec.

Package version

1.7.1

Node.js version

22.22.2

VitePress version

1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions