Skip to content

fix(auth): refactor initializeAuth for improved token handling and us… - #191

Merged
salehahmed99 merged 1 commit into
devfrom
feat/intersts-after-Oauth
Dec 16, 2025
Merged

fix(auth): refactor initializeAuth for improved token handling and us…#191
salehahmed99 merged 1 commit into
devfrom
feat/intersts-after-Oauth

Conversation

@MohamedAbdelaiem

Copy link
Copy Markdown
Collaborator

This pull request refactors the authentication initialization logic in useAuthStore to improve error handling and code clarity. The main change is restructuring the logic to handle errors in a more centralized way, reducing code duplication and ensuring that cleanup steps are consistently applied.

Authentication flow improvements:

  • Wrapped the entire initializeAuth logic in a single try-catch-finally block to centralize error handling and ensure that tokens and user state are always properly reset on failure. [1] [2]
  • Removed redundant nested try-catch blocks and simplified the logic for handling invalid tokens and refresh tokens, reducing code duplication and potential inconsistencies.
  • Ensured that the isInitialized state is always set to true in a finally block, guaranteeing that the app knows initialization is complete regardless of success or failure.…er state management

@salehahmed99
salehahmed99 merged commit c862264 into dev Dec 16, 2025
1 check passed
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.

2 participants