fix
This commit is contained in:
@@ -14,9 +14,7 @@ class AuthenticationRepository extends GetxController {
|
||||
final _auth = FirebaseAuth.instance;
|
||||
late final Rx<User?> firebaseUser;
|
||||
final firebase = FirebaseFirestore.instance;
|
||||
final GoogleSignIn googleSignIn = GoogleSignIn(
|
||||
clientId:
|
||||
'245204384533-glsp6hf14uqvtn52jrn1f9ds3k3too8v.apps.googleusercontent.com');
|
||||
final GoogleSignIn googleSignIn = GoogleSignIn();
|
||||
// final _userRef = firebase
|
||||
var verificationId = ''.obs;
|
||||
|
||||
@@ -128,15 +126,29 @@ class AuthenticationRepository extends GetxController {
|
||||
Future<void> signInWithGoogle() async {
|
||||
try {
|
||||
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser!.authentication;
|
||||
final credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
|
||||
if (googleUser != null) {
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser.authentication;
|
||||
final OAuthCredential credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
|
||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
|
||||
// Continúa con el flujo de la aplicación después del inicio de sesión exitoso
|
||||
// Por ejemplo, redirecciona a la siguiente pantalla
|
||||
firebaseUser.value != null
|
||||
? Get.offAll(ServiceScreen())
|
||||
: Get.to(LoginScreen());
|
||||
} else {
|
||||
// El usuario canceló el inicio de sesión con Google
|
||||
// Puedes manejarlo según tus necesidades
|
||||
print('Error');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error - ${e}');
|
||||
print('Error - $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user