feat(auth): Issue-691

This commit is contained in:
mso7nueh
2025-10-14 12:16:20 +03:00
parent 183fa012d2
commit 5354c3f517
7 changed files with 168 additions and 39 deletions

View File

@@ -1,3 +1,4 @@
import 'dart:developer';
import 'package:eatvio_app/features/auth/presentation/bloc/oauth_cubit/oauth_state.dart';
import 'package:eatvio_app/features/auth/repositories/auth_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -7,6 +8,23 @@ class OAuthCubit extends Cubit<OAuthState> {
OAuthCubit({required this.authRepository}) : super(const OAuthState());
Future<void> getOAuthLogin({required String provider, required String accessToken, required String refreshToken}) async {
try {
log('OAuthCubit: Starting OAuth login for provider: $provider');
emit(const OAuthState.loading());
log('OAuthCubit: Emitted loading state');
final tokenModel = await authRepository.getOAuthLogin(provider: provider, accessToken: accessToken, refreshToken: refreshToken);
log('OAuthCubit: Got token model: ${tokenModel.token}');
emit(OAuthState.loaded(token: tokenModel.token));
log('OAuthCubit: Emitted loaded state');
} catch (e) {
log('OAuthCubit: Error occurred: $e');
emit(OAuthState.error(errorMessage: e.toString()));
log('OAuthCubit: Emitted error state');
}
}
Future<void> getOAuthToken({
required String provider,
required String accessToken,
@@ -22,6 +40,7 @@ class OAuthCubit extends Cubit<OAuthState> {
required int height,
}) async {
try {
emit(const OAuthState.loading());
final token = await authRepository.getOAuthToken(
provider: provider,
accessToken: accessToken,