-
Notifications
You must be signed in to change notification settings - Fork 6
♻️ AuthStore refactor #613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
0fb1542
to
fc28bb3
Compare
fc28bb3
to
7afbe40
Compare
7afbe40
to
b3680c1
Compare
await userStore.login('skynet', 'terminator'); | ||
const { useAuthStore } = await import('../AuthStore'); | ||
const authStore = useAuthStore(); | ||
await authStore.login('skynet', 'terminator'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timely
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authStore.accessToken = undefined as any; | |
authStore.accessToken = null; |
AuthStore refactor
Checklist:
Summary:
Separate authentication logic from
UserStore
into a dedicatedAuthStore
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
AuthSotre
that integrates into the user store for better code organization.