fix login on guest
This commit is contained in:
parent
93c141a779
commit
2decbc43e5
4 changed files with 35 additions and 24 deletions
|
|
@ -6,6 +6,7 @@ import 'package:internet_connection_checker/internet_connection_checker.dart';
|
|||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/functions/bloc_getgueststatus.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/functions/bloc_setguestoff.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/functions/bloc_setgueston.dart';
|
||||
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/customer_title_widget.dart';
|
||||
|
|
@ -41,6 +42,17 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
|
|||
});
|
||||
}
|
||||
|
||||
void setGuest(bool value) async {
|
||||
// ignore: use_build_context_synchronously
|
||||
final success = value ? await blocSetGuestOn(context) : await blocSetGuestOff(context);
|
||||
|
||||
if (success) {
|
||||
setState(() {
|
||||
_isGuest = value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _signIn() async {
|
||||
final email = _emailController.text;
|
||||
final password = _passwordController.text;
|
||||
|
|
@ -80,9 +92,9 @@ class _CustomerCartPageState extends State<CustomerCartPage> {
|
|||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (user.contains('admin')) {
|
||||
if (mounted) context.push('/main');
|
||||
if (mounted) context.go('/main');
|
||||
} else {
|
||||
if (mounted) context.push('/customer');
|
||||
setGuest(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue