✨ Enhancement Description
Provide a brief description of the enhancement or improvement being suggested:
🌟 Benefits of the Enhancement
Explain how this enhancement will improve the project or user experience:
- Project Impact:
- Maintainability: Centralizing the refresh logic in
authMiddleware.ts (if feasible) avoids duplicating logic across the application and makes the authentication flow easier to manage and debug.
- Foundation for Future Features: Having a tested
refreshAuth function in authApi.ts is a prerequisite for any future feature that requires manual or automated session extension.
🛠️ Proposed Implementation
Outline how the enhancement could be implemented, including any technical considerations:
-
Technical Details:
- The new endpoint is documented in the Swagger UI:
https://devapi.altzone.fi/swagger#/Auth/AuthController. (Note: The documentation is behind authentication, ask if you don't have them).
- The implementation will require a way to test the new API function, as it won't be integrated into the main application flow yet.
- The middleware investigation will need to consider how to handle asynchronous operations, access the Redux store, and interact with
localStorage from within the middleware.
-
Implementation Plan:
- Add
refreshAuth function to authApi.ts:
- Implement refresh endpoint to
authApi.ts.
- Create a Test Mechanism:
- Create a simple, non-production page (e.g.,
/admin) with a button.
- The button's
onClick handler will call the new refreshAuth function from authApi.ts.
- Check localStorage for updates and if possible render the redux store on page.
- Investigate
authMiddleware.ts Integration:
- Analyze the current
authMiddleware.ts to understand its structure.
- On a successful refresh, dispatch a Redux action to update the store.
- Simultaneously, update the
localStorage with the new token data to ensure persistence across sessions.
- Document the findings, including potential challenges, proposed code structure, and any required changes to the Redux
authSlice.
📎 Additional Information
Include any additional context, examples, or resources that could help in understanding or implementing the enhancement:
✨ Enhancement Description
Provide a brief description of the enhancement or improvement being suggested:
What is it?: This issue covers two related tasks:
authApi.tsthat calls the backend's token refresh endpoint. This function will not be implemented in the application's logic yet, but will be added to the API layer for future use.authMiddleware.ts. The goal is to have the middleware automatically handle token refreshing and subsequently update both the Redux store andlocalStoragewith the new authentication data.Why improve it?: Only way to fetch fresh auth data is via login currently.
🌟 Benefits of the Enhancement
Explain how this enhancement will improve the project or user experience:
authMiddleware.ts(if feasible) avoids duplicating logic across the application and makes the authentication flow easier to manage and debug.refreshAuthfunction inauthApi.tsis a prerequisite for any future feature that requires manual or automated session extension.🛠️ Proposed Implementation
Outline how the enhancement could be implemented, including any technical considerations:
Technical Details:
https://devapi.altzone.fi/swagger#/Auth/AuthController. (Note: The documentation is behind authentication, ask if you don't have them).localStoragefrom within the middleware.Implementation Plan:
refreshAuthfunction toauthApi.ts:authApi.ts./admin) with a button.onClickhandler will call the newrefreshAuthfunction fromauthApi.ts.authMiddleware.tsIntegration:authMiddleware.tsto understand its structure.localStoragewith the new token data to ensure persistence across sessions.authSlice.📎 Additional Information
Include any additional context, examples, or resources that could help in understanding or implementing the enhancement: