Skip to content
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

Refactor login page state management and update dependencies #2348

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 4 additions & 9 deletions mobile-v3/lib/src/app/auth/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ class LoginPage extends StatefulWidget {

class _LoginPageState extends State<LoginPage> {
String? error;
AuthBloc? authBloc;
TextEditingController emailController = TextEditingController(
// text: "[email protected]",
);
TextEditingController passwordController = TextEditingController(
// text: "0134t34%Wer",
);
late AuthBloc authBloc;
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
GlobalKey<FormState> formKey = GlobalKey<FormState>();

@override
Expand All @@ -51,8 +47,6 @@ class _LoginPageState extends State<LoginPage> {
setState(() {
error = state.message.replaceAll("Exception: ", "");
});
// ScaffoldMessenger.of(context)
// .showSnackBar(SnackBar(content: Text(state.message)));
}
},
child: Scaffold(
Expand Down Expand Up @@ -105,6 +99,7 @@ class _LoginPageState extends State<LoginPage> {
),
),
validator: (value) {

if (value == null || value.isEmpty) {
return "This field cannot be blank.";
}
Comment on lines +113 to 116
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider implementing stronger password validation

The current validation only checks for empty values. Consider adding password complexity requirements for better security.

  validator: (value) {
+   final password = value?.trim() ?? '';
    if (value == null || value.isEmpty) {
      return "This field cannot be blank.";
    }
+   if (password.length < 8) {
+     return "Password must be at least 8 characters long";
+   }
+   if (!password.contains(RegExp(r'[A-Z]'))) {
+     return "Password must contain at least one uppercase letter";
+   }
+   if (!password.contains(RegExp(r'[0-9]'))) {
+     return "Password must contain at least one number";
+   }
    return null;
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (value == null || value.isEmpty) {
return "This field cannot be blank.";
}
validator: (value) {
final password = value?.trim() ?? '';
if (value == null || value.isEmpty) {
return "This field cannot be blank.";
}
if (password.length < 8) {
return "Password must be at least 8 characters long";
}
if (!password.contains(RegExp(r'[A-Z]'))) {
return "Password must contain at least one uppercase letter";
}
if (!password.contains(RegExp(r'[0-9]'))) {
return "Password must contain at least one number";
}
return null;
},

Expand Down
12 changes: 6 additions & 6 deletions mobile-v3/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1"
sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
version: "5.0.0"
flutter_loggy:
dependency: "direct main"
description:
Expand Down Expand Up @@ -473,10 +473,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
sha256: "00f33b908655e606b86d2ade4710a231b802eec6f11e87e4ea3783fd72077a50"
url: "https://pub.dev"
source: hosted
version: "0.19.0"
version: "0.20.1"
io:
dependency: transitive
description:
Expand Down Expand Up @@ -545,10 +545,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "5.0.0"
logger:
dependency: "direct main"
description:
Expand Down
4 changes: 2 additions & 2 deletions mobile-v3/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies:
shimmer: ^3.0.0
flutter_sticky_header: ^0.7.0
flutter_dotenv: ^5.1.0
intl: ^0.19.0
intl: ^0.20.1
google_maps_flutter: ^2.7.1
flutter_card_swiper: ^7.0.1
logger: ^2.5.0
Expand All @@ -66,7 +66,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^3.0.0
flutter_lints: ^5.0.0
build_runner:
json_serializable:

Expand Down
Loading