fAdd phone number support to user authentication events and methods
This commit is contained in:
@@ -73,6 +73,7 @@ class AuthRepository {
|
||||
/// [password] - User's password
|
||||
/// [nom] - User's last name
|
||||
/// [prenom] - User's first name
|
||||
/// [phoneNumber] - User's phone number
|
||||
///
|
||||
/// Returns the created [User] model if successful.
|
||||
/// Throws an exception if account creation fails.
|
||||
@@ -81,6 +82,7 @@ class AuthRepository {
|
||||
required String password,
|
||||
required String nom,
|
||||
required String prenom,
|
||||
required String phoneNumber,
|
||||
}) async {
|
||||
try {
|
||||
final firebaseUser = await _authService.signUpWithEmailAndPassword(
|
||||
@@ -94,7 +96,7 @@ class AuthRepository {
|
||||
email: email,
|
||||
nom: nom,
|
||||
prenom: prenom,
|
||||
phoneNumber: 'Uknown',
|
||||
phoneNumber: phoneNumber,
|
||||
platform: 'email',
|
||||
profilePictureUrl: '',
|
||||
);
|
||||
@@ -114,7 +116,7 @@ class AuthRepository {
|
||||
///
|
||||
/// Returns the [User] model if successful, null if Google sign-in was cancelled.
|
||||
/// Throws an exception if authentication fails.
|
||||
Future<User?> signInWithGoogle() async {
|
||||
Future<User?> signUpWithGoogle(String phoneNumber) async {
|
||||
try {
|
||||
final firebaseUser = await _authService.signInWithGoogle();
|
||||
|
||||
@@ -132,8 +134,8 @@ class AuthRepository {
|
||||
email: firebaseUser.user!.email ?? '',
|
||||
nom: '',
|
||||
prenom: firebaseUser.user!.displayName ?? 'User',
|
||||
phoneNumber: firebaseUser.user!.phoneNumber ?? 'Uknown',
|
||||
profilePictureUrl: firebaseUser.user!.photoURL,
|
||||
phoneNumber: phoneNumber,
|
||||
profilePictureUrl: firebaseUser.user!.photoURL ?? 'Unknown',
|
||||
platform: 'google',
|
||||
);
|
||||
|
||||
@@ -147,6 +149,21 @@ class AuthRepository {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<User?> signInWithGoogle() async {
|
||||
try {
|
||||
final firebaseUser = await _authService.signInWithGoogle();
|
||||
final user = await getUserFromFirestore(firebaseUser.user!.uid);
|
||||
if (user != null) {
|
||||
return user;
|
||||
} else {
|
||||
throw Exception('Utilisateur non trouvé');
|
||||
}
|
||||
} catch (e) {
|
||||
_errorService.showError(message: 'Erreur lors de la connexion Google');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Signs in a user using Apple authentication.
|
||||
///
|
||||
/// Handles Apple sign-in flow and creates/retrieves user data from Firestore.
|
||||
@@ -154,7 +171,7 @@ class AuthRepository {
|
||||
///
|
||||
/// Returns the [User] model if successful, null if Apple sign-in was cancelled.
|
||||
/// Throws an exception if authentication fails.
|
||||
Future<User?> signInWithApple() async {
|
||||
Future<User?> signUpWithApple(String phoneNumber) async {
|
||||
try {
|
||||
final firebaseUser = await _authService.signInWithApple();
|
||||
|
||||
@@ -170,8 +187,8 @@ class AuthRepository {
|
||||
email: firebaseUser.user!.email ?? '',
|
||||
nom: '',
|
||||
prenom: firebaseUser.user!.displayName ?? 'User',
|
||||
phoneNumber: firebaseUser.user!.phoneNumber ?? 'Uknown',
|
||||
profilePictureUrl: firebaseUser.user!.photoURL,
|
||||
phoneNumber: phoneNumber,
|
||||
profilePictureUrl: firebaseUser.user!.photoURL ?? 'Unknown',
|
||||
platform: 'apple',
|
||||
);
|
||||
|
||||
@@ -185,6 +202,21 @@ class AuthRepository {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<User?> signInWithApple() async {
|
||||
try {
|
||||
final firebaseUser = await _authService.signInWithApple();
|
||||
final user = await getUserFromFirestore(firebaseUser.user!.uid);
|
||||
if (user != null) {
|
||||
return user;
|
||||
} else {
|
||||
throw Exception('Utilisateur non trouvé');
|
||||
}
|
||||
} catch (e) {
|
||||
_errorService.showError(message: 'Erreur lors de la connexion Apple');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Signs out the current user.
|
||||
///
|
||||
/// Clears the authentication state and signs out from Firebase Auth.
|
||||
|
||||
Reference in New Issue
Block a user