Skip to content

Commit

Permalink
Rename Pass to Password, add kPasswordResetTimeoutInSeconds
Browse files Browse the repository at this point in the history
  • Loading branch information
GoranPrime committed Feb 20, 2025
1 parent 704b0f9 commit 041a062
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 18 deletions.
4 changes: 1 addition & 3 deletions packages/rx_bloc_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
## [5.6.0]
* Added Forgotten password feature in the generated project

## [5.5.0]
* Added change email feature in the generated project
* Added change phone number feature in the generated project
* Added Forgotten password feature in the generated project

## [5.4.1]
* Fix static analysis issue with multiline if statement brackets after linter update
Expand Down
2 changes: 1 addition & 1 deletion packages/rx_bloc_cli/bin/compile_test_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function replace_file_contents() {
"docs/patrol_integration_test.md" "https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/patrol_integration_test.md"
"docs/feature_creation.md" "https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/feature_creation.md"
"docs/onboarding_api_contracts.md" "https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/onboarding_api_contracts.md"
"docs/forgotten_pass_api_contracts.md" "https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/forgotten_pass_api_contracts.md"
"docs/forgotten_password_api_contracts.md" "https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/forgotten_password_api_contracts.md"
)

# Iterate over the to_replace array
Expand Down
4 changes: 2 additions & 2 deletions packages/rx_bloc_cli/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ The Forgotten password feature lets a registered user reset their password and s
The flow includes screens which allow the user to provide their email and continue with a link to reset.
When that link is opened, the user can set their new password.

For details on the API contracts used in the Forgotten password feature, please refer to the [API contracts][feature_forgotten_pass_api].
For details on the API contracts used in the Forgotten password feature, please refer to the [API contracts][feature_forgotten_password_api].


## Next Steps
Expand Down Expand Up @@ -614,4 +614,4 @@ For details on the API contracts used in the Forgotten password feature, please
[rx_bloc_cli_mfa_lnk]: https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/mfa.md
[feature_creation]: https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/feature_creation.md
[feature_onboarding_api]: https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/onboarding_api_contracts.md
[feature_forgotten_pass_api]: https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/forgotten_pass_api_contracts.md
[feature_forgotten_password_api]: https://github.com/Prime-Holding/rx_bloc/blob/master/packages/rx_bloc_cli/example/docs/forgotten_password_api_contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class GeneratorArguments
@override
bool get onboardingEnabled => _featureConfiguration.onboardingEnabled;

/// Forgotten pass feature
/// Forgotten Password feature
@override
bool get forgottenPassword => _featureConfiguration.forgottenPassword;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class GeneratorArgumentsProvider {
!(loginEnabled || socialLoginsEnabled)) {
// Modify feature flag or throw exception
_logger.warn(
'Login enabled, due to OTP/PIN/Onboarding/Forgotten Pass feature requirement');
'Login enabled, due to OTP/PIN/Onboarding/Forgotten Password feature requirement');
loginEnabled = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:{{project_name}}/base/models/confirmed_credentials_model.dart';
import 'package:{{project_name}}/base/models/user_model.dart';
import 'package:{{project_name}}/base/models/user_role.dart';

const kPasswordResetTimeoutInSeconds = 60;

class UsersRepository {
final List<UserModel> _registeredUsers = [];
final Map<String, String> _passwords = {};
Expand Down Expand Up @@ -80,10 +82,10 @@ class UsersRepository {
_passwordResetLockedUsers.keys.contains(email);

int getPasswordResetTimeoutForUser(String email) =>
_passwordResetLockedUsers[email] ?? 60;
_passwordResetLockedUsers[email] ?? kPasswordResetTimeoutInSeconds;

void lockPasswordResetForUser(String email) =>
_passwordResetLockedUsers[email] = 60;
_passwordResetLockedUsers[email] = kPasswordResetTimeoutInSeconds;

void decrementPasswordResetTimeoutForUser(String email) =>
_passwordResetLockedUsers.update(email, (timeout) => --timeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class UsersService {
Timer.periodic(
const Duration(seconds: 1),
(timer) {
if (timer.tick == 60) {
if (timer.tick == kPasswordResetTimeoutInSeconds) {
_usersRepository.unlockPasswordResetForUser(email);
return timer.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class PasswordResetBloc extends $PasswordResetBloc {
final CredentialsValidatorService _validatorService;
final RouterBlocType _routerBloc;

/// The token received from the Email link, to be checked by the backend
final String _token;
/// The Email of the user, to be used in case of resending the link
final String _email;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"tokenResent": "Нова връзка за нулиране на вашата парола е изпратена на вашия имейл адрес.",
"resetSuccess": "Вашата парола е успешно нулирана!",

"retry" : "Опитай отново",
"continueText" : "Продължи",
"confirm" : "Потвърди"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"tokenResent": "A new link to reset your password has been sent to your email address.",
"resetSuccess": "Your password has been successfully reset!",

"retry" : "Retry",
"continueText" : "Continue",
"confirm" : "Confirm"
}
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ The Forgotten password feature lets a registered user reset their password and s
The flow includes screens which allow the user to provide their email and continue with a link to reset.
When that link is opened, the user can set their new password.

For details on the API contracts used in the Forgotten password feature, please refer to the [API contracts][feature_forgotten_pass_api].
For details on the API contracts used in the Forgotten password feature, please refer to the [API contracts][feature_forgotten_password_api].
{{/enable_forgotten_password}}

## Next Steps
Expand Down Expand Up @@ -614,4 +614,4 @@ For details on the API contracts used in the Forgotten password feature, please
[rx_bloc_cli_mfa_lnk]: docs/mfa.md
[feature_creation]: docs/feature_creation.md
[feature_onboarding_api]: docs/onboarding_api_contracts.md
[feature_forgotten_pass_api]: docs/forgotten_pass_api_contracts.md
[feature_forgotten_password_api]: docs/forgotten_password_api_contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_rx_bloc/flutter_rx_bloc.dart';
import 'package:rx_bloc/rx_bloc.dart';
import 'package:widget_toolkit/widget_toolkit.dart' hide ErrorModel;

import '../../app_extensions.dart';
import '../extensions/error_model_translations.dart';
import '../models/errors/error_model.dart';

Expand All @@ -17,14 +18,14 @@ class AppErrorModalWidget<BlocType extends RxBlocTypeBase>
required this.errorState,
this.onRetry,
this.onCancel,
this.retryButtonText = 'Retry',
this.retryButtonText,
super.key,
});

final ErrorStateCallback<BlocType> errorState;
final Function(BuildContext, ErrorModel)? onRetry;
final Function()? onCancel;
final String retryButtonText;
final String? retryButtonText;

@override
Widget build(BuildContext context) => RxBlocListener<BlocType, ErrorModel>(
Expand All @@ -42,7 +43,7 @@ class AppErrorModalWidget<BlocType extends RxBlocTypeBase>
Navigator.of(context).pop();
},
onCancelCallback: onCancel,
retryButtonText: retryButtonText,
retryButtonText: retryButtonText ?? context.l10n.retry,
)
: showBlurredBottomSheet(
context: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"resetPassword": "Нулиране на парола",
"pageWithResult": "Въведете съобщение",
"tryAgain" : "Опитайте отново",
"retry" : "Опитай отново",
"confirm" : "Потвърдете",
"submit" : "Изпращане",
"continueText": "Продължи",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"resetPassword" : "Reset password",
"pageWithResult" : "Enter message",
"tryAgain" : "Try again",
"retry" : "Retry",
"confirm" : "Confirm",
"submit" : "Submit",
"continueText": "Continue",
Expand Down

0 comments on commit 041a062

Please sign in to comment.