Compare commits
No commits in common. "c7b241de2d5d8a7f925c15bac31b26ffc263ac46" and "37e00fe9c40515fb150566686639693781d0a17f" have entirely different histories.
c7b241de2d
...
37e00fe9c4
@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// 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_authentication_bloc/wyatt_authentication_bloc.dart';
|
||||||
import 'package:wyatt_type_utils/wyatt_type_utils.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
|
@override
|
||||||
Future<bool> verifyPasswordResetCode({required String code}) async {
|
Future<bool> verifyPasswordResetCode({required String code}) async {
|
||||||
try {
|
try {
|
||||||
|
@ -123,25 +123,6 @@ class AuthenticationMockDataSourceImpl extends AuthenticationRemoteDataSource {
|
|||||||
return Future.value(mock);
|
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
|
@override
|
||||||
Future<Account> signInWithEmailAndPassword({
|
Future<Account> signInWithEmailAndPassword({
|
||||||
required String email,
|
required String email,
|
||||||
|
@ -295,17 +295,6 @@ class AuthenticationRepositoryImpl<T extends Object>
|
|||||||
(error) => error,
|
(error) => error,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
FutureOrResult<Account> signInWithGoogle() =>
|
|
||||||
Result.tryCatchAsync<Account, AppException, AppException>(
|
|
||||||
() async {
|
|
||||||
final account =
|
|
||||||
await _authenticationRemoteDataSource.signInWithGoogle();
|
|
||||||
return account;
|
|
||||||
},
|
|
||||||
(error) => error,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FutureOrResult<bool> verifyPasswordResetCode({required String code}) =>
|
FutureOrResult<bool> verifyPasswordResetCode({required String code}) =>
|
||||||
Result.tryCatchAsync<bool, AppException, AppException>(
|
Result.tryCatchAsync<bool, AppException, AppException>(
|
||||||
|
@ -49,8 +49,6 @@ abstract class AuthenticationRemoteDataSource extends BaseRemoteDataSource {
|
|||||||
|
|
||||||
Future<Account> signInAnonymously();
|
Future<Account> signInAnonymously();
|
||||||
|
|
||||||
Future<Account> signInWithGoogle();
|
|
||||||
|
|
||||||
Future<Account> updateEmail({required String email});
|
Future<Account> updateEmail({required String email});
|
||||||
|
|
||||||
Future<Account> updatePassword({required String password});
|
Future<Account> updatePassword({required String password});
|
||||||
|
@ -73,13 +73,6 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
|
|||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
FutureOrResult<Account> signInAnonymously();
|
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}
|
/// {@template signin_pwd}
|
||||||
/// Signs in with the provided [email] and [password].
|
/// Signs in with the provided [email] and [password].
|
||||||
///
|
///
|
||||||
|
@ -17,7 +17,4 @@
|
|||||||
/// An authentication library for BLoC.
|
/// An authentication library for BLoC.
|
||||||
library wyatt_authentication_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';
|
export 'src/src.dart';
|
||||||
|
@ -10,12 +10,17 @@ environment:
|
|||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter: { sdk: flutter }
|
flutter:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
crypto: ^3.0.2
|
crypto: ^3.0.2
|
||||||
flutter_bloc: ^8.1.1
|
flutter_bloc: ^8.1.1
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
firebase_auth: ^4.2.0
|
firebase_auth: ^4.1.1
|
||||||
google_sign_in: ^5.4.2
|
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
|
rxdart: ^0.27.7
|
||||||
|
|
||||||
wyatt_form_bloc:
|
wyatt_form_bloc:
|
||||||
@ -31,7 +36,8 @@ dependencies:
|
|||||||
version: ^0.0.4
|
version: ^0.0.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test: { sdk: flutter }
|
flutter_test:
|
||||||
|
sdk: flutter
|
||||||
bloc_test: ^9.1.0
|
bloc_test: ^9.1.0
|
||||||
mocktail: ^0.3.0
|
mocktail: ^0.3.0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user