Add auto-login after password reset on iOS and Android
- Add LOGGING_IN step to PasswordResetStep enum on both platforms - Auto-login with new credentials after successful password reset - Navigate directly to main app (or verification screen if unverified) - Show "Logging in..." state during auto-login process - Hide back button during auto-login to prevent interruption - Fall back to "Return to Login" if auto-login fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,7 @@ fun ResetPasswordScreen(
|
||||
var confirmPasswordVisible by remember { mutableStateOf(false) }
|
||||
|
||||
val resetPasswordState by viewModel.resetPasswordState.collectAsState()
|
||||
val loginState by viewModel.loginState.collectAsState()
|
||||
val currentStep by viewModel.currentStep.collectAsState()
|
||||
|
||||
// Handle errors for password reset
|
||||
@@ -50,6 +51,7 @@ fun ResetPasswordScreen(
|
||||
}
|
||||
|
||||
val isLoading = resetPasswordState is ApiResult.Loading
|
||||
val isLoggingIn = currentStep == com.example.casera.viewmodel.PasswordResetStep.LOGGING_IN
|
||||
val isSuccess = currentStep == com.example.casera.viewmodel.PasswordResetStep.SUCCESS
|
||||
|
||||
// Password validation
|
||||
@@ -63,9 +65,12 @@ fun ResetPasswordScreen(
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(Res.string.auth_reset_title)) },
|
||||
navigationIcon = {
|
||||
onNavigateBack?.let { callback ->
|
||||
IconButton(onClick = callback) {
|
||||
Icon(Icons.Default.ArrowBack, contentDescription = stringResource(Res.string.common_back))
|
||||
// Hide back button while logging in
|
||||
if (!isLoggingIn) {
|
||||
onNavigateBack?.let { callback ->
|
||||
IconButton(onClick = callback) {
|
||||
Icon(Icons.Default.ArrowBack, contentDescription = stringResource(Res.string.common_back))
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -239,15 +244,21 @@ fun ResetPasswordScreen(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(56.dp),
|
||||
enabled = isFormValid && !isLoading,
|
||||
enabled = isFormValid && !isLoading && !isLoggingIn,
|
||||
shape = RoundedCornerShape(12.dp)
|
||||
) {
|
||||
if (isLoading) {
|
||||
if (isLoading || isLoggingIn) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(24.dp),
|
||||
color = MaterialTheme.colorScheme.onPrimary,
|
||||
strokeWidth = 2.dp
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
if (isLoggingIn) "Logging in..." else "Resetting...",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.SemiBold
|
||||
)
|
||||
} else {
|
||||
Icon(Icons.Default.LockReset, contentDescription = null)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
|
||||
Reference in New Issue
Block a user