forked from eatvio/eatvio_app
feat(auth): implement OAuth verification request and confirmation flow with error handling and UI updates
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import 'dart:developer';
|
||||
import 'package:eatvio_app/features/auth/models/credentials_model.dart';
|
||||
import 'package:eatvio_app/features/auth/models/oauth_model.dart';
|
||||
import 'package:eatvio_app/features/auth/models/oauth_login_request.dart';
|
||||
import 'package:eatvio_app/features/auth/models/oauth_verification_confirm_request.dart';
|
||||
import 'package:eatvio_app/features/auth/models/oauth_verification_confirm_response.dart';
|
||||
import 'package:eatvio_app/features/auth/models/oauth_verification_request.dart';
|
||||
import 'package:eatvio_app/features/auth/models/oauth_verification_request_response.dart';
|
||||
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
||||
import 'package:eatvio_app/features/auth/services/auth_service.dart';
|
||||
|
||||
@@ -19,7 +24,6 @@ class AuthRepository {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<TokenModel> signInViaSocialMedia({
|
||||
required String provider,
|
||||
required String accessToken,
|
||||
@@ -73,4 +77,60 @@ class AuthRepository {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<OAuthVerificationRequestResponse> requestOAuthVerification({String? email, String? phone}) async {
|
||||
try {
|
||||
return await authService.requestOAuthVerification(
|
||||
body: OAuthVerificationRequest(email: email, phone: phone),
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<OAuthVerificationConfirmResponse> confirmOAuthVerification({
|
||||
required String provider,
|
||||
required String accessToken,
|
||||
required String refreshToken,
|
||||
required String clientId,
|
||||
required String id,
|
||||
String? email,
|
||||
String? phone,
|
||||
required String code,
|
||||
required String verificationType,
|
||||
required String firstName,
|
||||
required String lastName,
|
||||
required String dateOfBirth,
|
||||
required String gender,
|
||||
required int weight,
|
||||
required int height,
|
||||
}) async {
|
||||
try {
|
||||
final request = OAuthVerificationConfirmRequest(
|
||||
provider: provider,
|
||||
accessToken: accessToken,
|
||||
refreshToken: refreshToken,
|
||||
clientId: clientId,
|
||||
id: id,
|
||||
email: email,
|
||||
phone: phone,
|
||||
code: code,
|
||||
verificationType: verificationType,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
dateOfBirth: dateOfBirth,
|
||||
gender: gender,
|
||||
weight: weight,
|
||||
height: height,
|
||||
);
|
||||
// Логируем запрос перед отправкой
|
||||
log(
|
||||
'AuthRepository: Sending OAuth verification confirm request: provider=$provider, verificationType=$verificationType, code=$code, email=$email, phone=$phone',
|
||||
);
|
||||
return await authService.confirmOAuthVerification(body: request);
|
||||
} catch (e) {
|
||||
log('AuthRepository: Error in confirmOAuthVerification: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user