forked from eatvio/eatvio_app
chats have been updated to work with consultatons
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/core/utils/toasts.dart';
|
||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_state.dart';
|
||||
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
|
||||
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
@@ -15,7 +13,7 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
required this.authRepository,
|
||||
}) : super(AuthState());
|
||||
|
||||
getTokenByCredentials(String email, String password) async {
|
||||
Future<bool> getTokenByCredentials(String email, String password) async {
|
||||
emit(AuthState.loading());
|
||||
try {
|
||||
final token = (await authRepository.getTokenByCredentials(
|
||||
@@ -23,7 +21,6 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
password,
|
||||
))
|
||||
.token;
|
||||
print(token);
|
||||
emit(
|
||||
AuthState.loaded(
|
||||
token: token,
|
||||
@@ -31,12 +28,13 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
);
|
||||
showSuccessToast('Успешный вход');
|
||||
await TokenStorage.saveTokenInStorage(token);
|
||||
await sl<ProfileAvatarCubit>().getMyProfile();
|
||||
AppRouter.navigatorKey.currentContext?.go('/my-profile-screen');
|
||||
return true;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
showErrorToast('Неверный адрес электронной почты или пароль');
|
||||
emit(AuthState.error(errorMessage: '$e'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user