update
This commit is contained in:
parent
87d8bb483e
commit
17a1430ef0
11 changed files with 271 additions and 25 deletions
|
|
@ -10,6 +10,7 @@ import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
|||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
|
@ -32,11 +33,26 @@ class _LoginPageState extends State<LoginPage> {
|
|||
final email = _emailController.text;
|
||||
final password = _passwordController.text;
|
||||
|
||||
if (email.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Please enter a valid email', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Please enter a password', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
await _authService.signIn(email, password);
|
||||
|
||||
if (mounted) {
|
||||
showNotification(context, 'Login Successful', true);
|
||||
|
||||
|
|
@ -52,8 +68,15 @@ class _LoginPageState extends State<LoginPage> {
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: $e', false);
|
||||
if (e is AuthException) {
|
||||
final errorMessage = e.message;
|
||||
|
||||
if (mounted) {
|
||||
// showNotification(context, 'Error: $errorMessage', false);
|
||||
if (errorMessage == 'Invalid login credentials') {
|
||||
showNotification(context, 'Error: Invalid Email or Password', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue