login
This commit is contained in:
@@ -28,27 +28,39 @@ class AuthRepositoryImpl implements AuthRepository {
|
||||
required String password,
|
||||
}) async {
|
||||
try {
|
||||
print('🔐 Repository: Starting login...');
|
||||
final loginDto = LoginDto(email: email, password: password);
|
||||
final authResponse = await remoteDataSource.login(loginDto);
|
||||
|
||||
print('🔐 Repository: Got response, token length=${authResponse.accessToken.length}');
|
||||
|
||||
// Save token to secure storage
|
||||
await secureStorage.saveAccessToken(authResponse.accessToken);
|
||||
print('🔐 Repository: Token saved to secure storage');
|
||||
|
||||
// Set token in Dio client for subsequent requests
|
||||
dioClient.setAuthToken(authResponse.accessToken);
|
||||
print('🔐 Repository: Token set in DioClient');
|
||||
|
||||
return Right(authResponse);
|
||||
} on InvalidCredentialsException catch (e) {
|
||||
print('❌ Repository: InvalidCredentialsException - ${e.message}');
|
||||
return Left(InvalidCredentialsFailure(e.message));
|
||||
} on UnauthorizedException catch (e) {
|
||||
print('❌ Repository: UnauthorizedException - ${e.message}');
|
||||
return Left(UnauthorizedFailure(e.message));
|
||||
} on ValidationException catch (e) {
|
||||
print('❌ Repository: ValidationException - ${e.message}');
|
||||
return Left(ValidationFailure(e.message));
|
||||
} on NetworkException catch (e) {
|
||||
print('❌ Repository: NetworkException - ${e.message}');
|
||||
return Left(NetworkFailure(e.message));
|
||||
} on ServerException catch (e) {
|
||||
print('❌ Repository: ServerException - ${e.message}');
|
||||
return Left(ServerFailure(e.message));
|
||||
} catch (e) {
|
||||
} catch (e, stackTrace) {
|
||||
print('❌ Repository: Unexpected error - $e');
|
||||
print('Stack trace: $stackTrace');
|
||||
return Left(ServerFailure('Unexpected error: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user