Skip to content

Conversation

C-Valen
Copy link
Member

@C-Valen C-Valen commented Aug 21, 2025

AuthStore refactor

Checklist:

  • Commits consolidated
  • [-] Changelog updated
  • Test cases added/updated
  • [-] Integration tests updated
  • [-] Jira ticket updated

Summary:

Separate authentication logic from UserStore into a dedicated AuthStore for better separation of concerns.

Changes:

✨ New AuthStore: Handles login/logout, token management, and authentication state
♻️ UserStore refactoring: Removed auth logic, kept only user data management
♻️ Component updates: Login, Navbar, and other components now use AuthStore
♻️ Service updates: OsidbAuthService switched to AuthStore
♻️ Composable updates: useSessionWarning now uses AuthStore
♻️ Router updates: Authentication checks moved to AuthStore
✅ Test updates: All tests updated for new store separation

Considerations:

Extension of #598 to make an AuthSotrethat integrates into the user store for better code organization.

@C-Valen C-Valen self-assigned this Aug 21, 2025
@C-Valen C-Valen added the internal Skip Jira CI label Aug 21, 2025
@C-Valen C-Valen changed the title 🚧 AuthStore refactor WIP ♻️ AuthStore refactor WIP Sep 19, 2025
@C-Valen C-Valen changed the title ♻️ AuthStore refactor WIP ♻️ AuthStore refactor Sep 19, 2025
@C-Valen C-Valen requested a review from a team September 19, 2025 12:31
@C-Valen C-Valen marked this pull request as ready for review September 19, 2025 12:56
await userStore.login('skynet', 'terminator');
const { useAuthStore } = await import('../AuthStore');
const authStore = useAuthStore();
await authStore.login('skynet', 'terminator');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timely

Copy link
Collaborator

@superbuggy superbuggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks great. Couple questions about some type handling.


expect(() => {
userStore.accessToken = 'invalid';
authStore.accessToken = 'invalid' as any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does TS complain here? Seems like it should be fine with being a string

userStore.accessToken = undefined;
expect(userStore.isAccessTokenExpired()).toBe(true);
const authStore = useAuthStore();
authStore.accessToken = undefined as any;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
authStore.accessToken = undefined as any;
authStore.accessToken = null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Skip Jira CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants