feat(01-06): create password update page with validation
- Implemented UpdatePasswordPage with password strength indicator - Added password validation utility with comprehensive checks - Enhanced AuthProvider with updatePasswordFromReset method - Extended AuthRepository interface and implementation for password reset - Added InvalidTokenException to auth exception hierarchy - Includes accessibility features and error handling - Password strength indicator with real-time feedback Files: - lib/features/authentication/presentation/pages/update_password_page.dart - lib/core/utils/password_validator.dart - lib/providers/auth_provider.dart - lib/features/authentication/domain/repositories/auth_repository.dart - lib/features/authentication/data/repositories/auth_repository_impl.dart - lib/core/errors/auth_exceptions.dart
This commit is contained in:
@@ -302,6 +302,33 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updatePasswordFromReset(String newPassword) async {
|
||||
try {
|
||||
// Extract the current session to verify we have a valid reset token
|
||||
final session = _supabase.auth.currentSession;
|
||||
|
||||
if (session == null) {
|
||||
throw const InvalidTokenException(
|
||||
message: 'No valid password reset session found. Please request a new reset link.',
|
||||
code: 'NO_RESET_SESSION',
|
||||
);
|
||||
}
|
||||
|
||||
// Update password using Supabase updateUser
|
||||
await _supabase.auth.updateUser(
|
||||
UserAttributes(
|
||||
password: newPassword,
|
||||
),
|
||||
);
|
||||
|
||||
// After successful password update, sign out to force re-authentication
|
||||
await _supabase.auth.signOut();
|
||||
} catch (e) {
|
||||
throw AuthExceptionFactory.fromSupabaseError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// Dispose of any active subscriptions
|
||||
///
|
||||
/// Call this when the repository is no longer needed to prevent memory leaks
|
||||
|
||||
Reference in New Issue
Block a user