forked from eatvio/eatvio_app
fix: auth
This commit is contained in:
@@ -17,11 +17,12 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
getTokenByCredentials(String email, String password) async {
|
||||
emit(AuthState.loading());
|
||||
try {
|
||||
final String token = (await authRepository.getTokenByCredentials(
|
||||
final token = (await authRepository.getTokenByCredentials(
|
||||
email,
|
||||
password,
|
||||
))
|
||||
.token;
|
||||
print(token);
|
||||
emit(
|
||||
AuthState.loaded(
|
||||
token: token,
|
||||
@@ -31,6 +32,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
await sl<ProfileAvatarCubit>().getMyProfile();
|
||||
AppRouter.navigatorKey.currentContext?.go('/my-profile-screen');
|
||||
} catch (e) {
|
||||
print(e);
|
||||
emit(AuthState.error(errorMessage: '$e'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,14 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
final passwordController = TextEditingController();
|
||||
bool checkboxState = false;
|
||||
bool hidePassword = true;
|
||||
final authCubit = sl<AuthCubit>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
FlutterNativeSplash.remove();
|
||||
return BlocProvider<AuthCubit>(
|
||||
create: (BuildContext context) => sl<AuthCubit>(),
|
||||
create: (BuildContext context) => authCubit,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
@@ -131,7 +132,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
backgroundColor: appTheme.blueA400,
|
||||
onPressed: () => context.read<AuthCubit>().getTokenByCredentials(
|
||||
onPressed: () => authCubit.getTokenByCredentials(
|
||||
emailController.text,
|
||||
passwordController.text,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user