Compare commits

..

No commits in common. "c7b241de2d5d8a7f925c15bac31b26ffc263ac46" and "37e00fe9c40515fb150566686639693781d0a17f" have entirely different histories.

7 changed files with 11 additions and 79 deletions

View File

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:firebase_auth/firebase_auth.dart';
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart';
@ -181,39 +182,6 @@ class AuthenticationFirebaseDataSourceImpl
}
}
@override
Future<Account> signInWithGoogle() async {
try {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
// Obtain the auth details from the request
final GoogleSignInAuthentication? googleAuth =
await googleUser?.authentication;
// Create a new credential
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);
final userCredential =
await _firebaseAuth.signInWithCredential(credential);
_latestCreds = userCredential;
final user = userCredential.user;
if (user.isNotNull) {
return _mapper(user!);
} else {
throw Exception(); // Get caught just after.
}
} on FirebaseAuthException catch (e) {
throw SignInWithGoogleFailureFirebase.fromCode(e.code);
} catch (_) {
throw SignInWithGoogleFailureFirebase();
}
}
@override
Future<bool> verifyPasswordResetCode({required String code}) async {
try {

View File

@ -123,25 +123,6 @@ class AuthenticationMockDataSourceImpl extends AuthenticationRemoteDataSource {
return Future.value(mock);
}
@override
Future<Account> signInWithGoogle() async {
await _randomDelay();
final creation = DateTime.now();
final mock = AccountModel(
uid: 'mock-id-google',
emailVerified: true,
isAnonymous: false,
providerId: 'google',
creationTime: creation,
lastSignInTime: creation,
isNewUser: creation == creation,
);
_streamAccount.add(mock);
_connectedMock = _connectedMock?.copyWith(left: mock);
_lastSignInTime = DateTime.now();
return Future.value(mock);
}
@override
Future<Account> signInWithEmailAndPassword({
required String email,

View File

@ -295,17 +295,6 @@ class AuthenticationRepositoryImpl<T extends Object>
(error) => error,
);
@override
FutureOrResult<Account> signInWithGoogle() =>
Result.tryCatchAsync<Account, AppException, AppException>(
() async {
final account =
await _authenticationRemoteDataSource.signInWithGoogle();
return account;
},
(error) => error,
);
@override
FutureOrResult<bool> verifyPasswordResetCode({required String code}) =>
Result.tryCatchAsync<bool, AppException, AppException>(

View File

@ -49,8 +49,6 @@ abstract class AuthenticationRemoteDataSource extends BaseRemoteDataSource {
Future<Account> signInAnonymously();
Future<Account> signInWithGoogle();
Future<Account> updateEmail({required String email});
Future<Account> updatePassword({required String password});

View File

@ -73,13 +73,6 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// {@endtemplate}
FutureOrResult<Account> signInAnonymously();
/// {@template signin_google}
/// Starts the Sign In with Google Flow.
///
/// Throws a SignInWithGoogleFailureInterface if an exception occurs.
/// {@endtemplate}
FutureOrResult<Account> signInWithGoogle();
/// {@template signin_pwd}
/// Signs in with the provided [email] and [password].
///

View File

@ -17,7 +17,4 @@
/// An authentication library for BLoC.
library wyatt_authentication_bloc;
export 'package:firebase_auth/firebase_auth.dart';
export 'package:google_sign_in/google_sign_in.dart';
export 'src/src.dart';

View File

@ -10,12 +10,17 @@ environment:
flutter: ">=1.17.0"
dependencies:
flutter: { sdk: flutter }
flutter:
sdk: flutter
crypto: ^3.0.2
flutter_bloc: ^8.1.1
equatable: ^2.0.5
firebase_auth: ^4.2.0
google_sign_in: ^5.4.2
firebase_auth: ^4.1.1
google_sign_in: ^5.3.0
flutter_facebook_auth: ^4.3.0
sign_in_with_apple: ^3.3.0
twitter_login: ^4.2.3
rxdart: ^0.27.7
wyatt_form_bloc:
@ -31,7 +36,8 @@ dependencies:
version: ^0.0.4
dev_dependencies:
flutter_test: { sdk: flutter }
flutter_test:
sdk: flutter
bloc_test: ^9.1.0
mocktail: ^0.3.0