Conversation
* fix(auth): improve user identifier retrieval * updates
There was a problem hiding this comment.
Code Review
This pull request refactors the authentication flow to support direct navigation to a specific provider's screen when only one provider is configured, bypassing the method picker. It introduces extension functions in a new UserUtils.kt file for consistent user identification, improves the reliability of authStateFlow by incorporating an IdTokenListener to handle account linking, and updates navigation logic and tests to reflect these changes. The review feedback suggests using the user instance provided by the AuthState object directly in the UI layer for better consistency and idiomatic code.
| is AuthState.Success -> { | ||
| val user = uiContext.authUI.getCurrentUser() | ||
| val identifier = user?.email ?: user?.phoneNumber ?: user?.uid.orEmpty() | ||
| val identifier = user.displayIdentifier() |
There was a problem hiding this comment.
Since the state is already smart-cast to AuthState.Success in this block, you can use state.user directly instead of relying on the user variable retrieved from authUI.getCurrentUser(). This is more idiomatic as it ensures you are using the specific user instance that triggered the current state emission.
| val identifier = user.displayIdentifier() | |
| val identifier = state.user.displayIdentifier() |
|
|
||
| is AuthState.RequiresEmailVerification -> { | ||
| val email = uiContext.authUI.getCurrentUser()?.email ?: stringProvider.emailProvider | ||
| val email = uiContext.authUI.getCurrentUser().getDisplayEmail(stringProvider.emailProvider) |
There was a problem hiding this comment.
In the AuthState.RequiresEmailVerification block, you can use state.user directly instead of calling uiContext.authUI.getCurrentUser(). Using the data provided by the state object is safer and more consistent with Compose state management patterns.
| val email = uiContext.authUI.getCurrentUser().getDisplayEmail(stringProvider.emailProvider) | |
| val email = state.user.getDisplayEmail(stringProvider.emailProvider) |
Description