Skip to content

Enhance auth feature #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/authentication/bloc/authentication_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AuthenticationBloc

final AuthRepository _authenticationRepository;
late final StreamSubscription<User?> _userAuthSubscription;
Timer? _cooldownTimer;

/// Handles [_AuthenticationStatusChanged] events.
Future<void> _onAuthenticationStatusChanged(
Expand Down Expand Up @@ -97,7 +98,8 @@ class AuthenticationBloc
);

// Start a timer to transition out of cooldown
Timer(
_cooldownTimer?.cancel();
_cooldownTimer = Timer(
_requestCodeCooldownDuration,
() => add(const AuthenticationCooldownCompleted()),
);
Expand Down Expand Up @@ -213,6 +215,7 @@ class AuthenticationBloc
@override
Future<void> close() {
_userAuthSubscription.cancel();
_cooldownTimer?.cancel();
return super.close();
}
}
6 changes: 2 additions & 4 deletions lib/authentication/view/request_code_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,8 @@ class _EmailLinkFormState extends State<_EmailLinkForm> {
setState(() {
_cooldownSeconds = 0;
});
// Optionally, trigger an event to reset the bloc state if needed
context
.read<AuthenticationBloc>()
.add(const AuthenticationCooldownCompleted());
// The BLoC handles resetting its own state. The UI timer is only
// responsible for updating the countdown on the screen.
}
});
}
Expand Down
Loading