Skip to content

Commit 80700b6

Browse files
committed
feat: additional password validation on authentication
1 parent 8f2eb27 commit 80700b6

File tree

2 files changed

+326
-256
lines changed

2 files changed

+326
-256
lines changed

lib/features/auth/widgets/login_form.dart

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ class LoginForm extends StatelessWidget {
3232
// For simplicity, we'll put the navigation logic here, but for complex apps,
3333
// you might have a dedicated AuthWrapper or AuthStreamListener at a higher level.
3434
if (supabaseService.currentUser != null &&
35-
GoRouter.of(
36-
context,
37-
).routerDelegate.currentConfiguration.fullPath !=
35+
GoRouter.of(context).routerDelegate.currentConfiguration.fullPath !=
3836
RoutesPath.dashboard) {
3937
WidgetsBinding.instance.addPostFrameCallback((_) {
4038
// Check if current route is not already dashboard to prevent loop
@@ -193,15 +191,27 @@ class LoginForm extends StatelessWidget {
193191
onPressed: () async {
194192
// We set loading true, and it will be set to false in the provider's finally block
195193
// The navigation happens after the SupabaseService updates the current user
196-
String res = await authProvider.loginUser(
197-
email: authProvider.emailController.text,
198-
password: authProvider.passwordController.text,
194+
String? passwordValidationCheck = validatePassword(
195+
authProvider.passwordController.text,
199196
);
200-
if (res != "Logged in successfully") {
197+
if (passwordValidationCheck == null) {
198+
String res = await authProvider.loginUser(
199+
email: authProvider.emailController.text,
200+
password: authProvider.passwordController.text,
201+
);
202+
if (res != "Logged in successfully") {
203+
ScaffoldMessenger.of(context).showSnackBar(
204+
SnackBar(
205+
content: Text(res),
206+
duration: const Duration(seconds: 5),
207+
),
208+
);
209+
}
210+
} else {
201211
ScaffoldMessenger.of(context).showSnackBar(
202212
SnackBar(
203-
content: Text(res),
204-
duration: const Duration(seconds: 5),
213+
content: Text(passwordValidationCheck),
214+
duration: const Duration(seconds: 2),
205215
),
206216
);
207217
}

0 commit comments

Comments
 (0)