signOut
Signs out the currently authenticated user from Firebase and clears local session.
This method signs the user out from Firebase Authentication and clears the local authentication state. Note that this does NOT clear saved credentials from Android's Credential Manager - the user can still use one-tap sign-in after signing out.
Behavior
Clears Firebase Authentication session
Clears any cached user data
After sign-out, getCurrentUser will return null
Saved credentials in Credential Manager remain available
Use Cases
User-initiated sign out
Switching accounts
Security-related sign out (e.g., suspicious activity)
Thread Safety
This is a suspend function that performs async operations. Call from a coroutine context.
Example
// In your settings ViewModel
fun signOut() {
_uiState.updateWith {
authRepository.signOut()
}
}Note on Credential Manager
If you want to also clear saved credentials from Credential Manager, you need to call the Credential Manager API separately:
suspend fun signOutAndClearCredentials(context: Context) {
authDataSource.signOut()
// Additional code to clear Credential Manager credentials if needed
}