feat: Add entitlements file and update GoogleService-Info.plist for improved authentication support
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
67EC5B6326AB6B6B093D53CE /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
|
67EC5B6326AB6B6B093D53CE /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
69B9D71F2EB7E2C900F2639E /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||||
@@ -105,7 +106,6 @@
|
|||||||
67EC5B6326AB6B6B093D53CE /* Pods-RunnerTests.release.xcconfig */,
|
67EC5B6326AB6B6B093D53CE /* Pods-RunnerTests.release.xcconfig */,
|
||||||
F230D285980CEE0F11E7B0BC /* Pods-RunnerTests.profile.xcconfig */,
|
F230D285980CEE0F11E7B0BC /* Pods-RunnerTests.profile.xcconfig */,
|
||||||
);
|
);
|
||||||
name = Pods;
|
|
||||||
path = Pods;
|
path = Pods;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -144,6 +144,7 @@
|
|||||||
97C146F01CF9000F007C117D /* Runner */ = {
|
97C146F01CF9000F007C117D /* Runner */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
69B9D71F2EB7E2C900F2639E /* Runner.entitlements */,
|
||||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||||
@@ -339,10 +340,14 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
name = "[CP] Embed Pods Frameworks";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||||
@@ -371,10 +376,14 @@
|
|||||||
inputFileListPaths = (
|
inputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
name = "[CP] Copy Pods Resources";
|
name = "[CP] Copy Pods Resources";
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||||
);
|
);
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||||
@@ -488,6 +497,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
@@ -495,7 +505,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.travelMate;
|
PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -670,6 +680,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
@@ -677,7 +688,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.travelMate;
|
PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
@@ -692,6 +703,7 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
INFOPLIST_FILE = Runner/Info.plist;
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
@@ -699,7 +711,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.travelMate;
|
PRODUCT_BUNDLE_IDENTIFIER = be.devdayronvl.TravelMate;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>CLIENT_ID</key>
|
<key>CLIENT_ID</key>
|
||||||
<string>521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com</string>
|
<string>521527250907-196i04qgm4talrosgi0ne0q8en90hkkh.apps.googleusercontent.com</string>
|
||||||
<key>REVERSED_CLIENT_ID</key>
|
<key>REVERSED_CLIENT_ID</key>
|
||||||
<string>com.googleusercontent.apps.521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m</string>
|
<string>com.googleusercontent.apps.521527250907-196i04qgm4talrosgi0ne0q8en90hkkh</string>
|
||||||
<key>ANDROID_CLIENT_ID</key>
|
<key>ANDROID_CLIENT_ID</key>
|
||||||
<string>521527250907-lqgj1lmfcsjusm2be9r6kpuanq3jvjcd.apps.googleusercontent.com</string>
|
<string>521527250907-19lrclc10eb0p8li1qutepctfqdohn0b.apps.googleusercontent.com</string>
|
||||||
<key>API_KEY</key>
|
<key>API_KEY</key>
|
||||||
<string>AIzaSyBFaSzvcvO8qg7El-2jRf7WctZIMKNA4-I</string>
|
<string>AIzaSyBFaSzvcvO8qg7El-2jRf7WctZIMKNA4-I</string>
|
||||||
<key>GCM_SENDER_ID</key>
|
<key>GCM_SENDER_ID</key>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<key>PLIST_VERSION</key>
|
<key>PLIST_VERSION</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
<key>BUNDLE_ID</key>
|
<key>BUNDLE_ID</key>
|
||||||
<string>com.example.travelMate</string>
|
<string>be.devdayronvl.TravelMate</string>
|
||||||
<key>PROJECT_ID</key>
|
<key>PROJECT_ID</key>
|
||||||
<string>travelmate-a47f5</string>
|
<string>travelmate-a47f5</string>
|
||||||
<key>STORAGE_BUCKET</key>
|
<key>STORAGE_BUCKET</key>
|
||||||
@@ -31,6 +31,6 @@
|
|||||||
<key>IS_SIGNIN_ENABLED</key>
|
<key>IS_SIGNIN_ENABLED</key>
|
||||||
<true></true>
|
<true></true>
|
||||||
<key>GOOGLE_APP_ID</key>
|
<key>GOOGLE_APP_ID</key>
|
||||||
<string>1:521527250907:ios:64b41be39c54db1c7da1fe</string>
|
<string>1:521527250907:ios:52058410e09e5d3a7da1fe</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
|
<true/>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
@@ -20,10 +22,29 @@
|
|||||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>REVERSED_CLIENT_ID</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>com.googleusercontent.apps.521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||||
|
<key>GIDClientID</key>
|
||||||
|
<string>521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>NSLocationAlwaysUsageDescription</key>
|
||||||
|
<string>Cette application a besoin de votre position pour afficher votre localisation sur la carte</string>
|
||||||
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
|
<string>Cette application a besoin de votre position pour afficher votre localisation sur la carte</string>
|
||||||
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
|
<true/>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
<string>LaunchScreen</string>
|
<string>LaunchScreen</string>
|
||||||
<key>UIMainStoryboardFile</key>
|
<key>UIMainStoryboardFile</key>
|
||||||
@@ -41,27 +62,5 @@
|
|||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
|
||||||
<true/>
|
|
||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSLocationWhenInUseUsageDescription</key>
|
|
||||||
<string>Cette application a besoin de votre position pour afficher votre localisation sur la carte</string>
|
|
||||||
<key>NSLocationAlwaysUsageDescription</key>
|
|
||||||
<string>Cette application a besoin de votre position pour afficher votre localisation sur la carte</string>
|
|
||||||
<key>GIDClientID</key>
|
|
||||||
<string>521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m.apps.googleusercontent.com</string>
|
|
||||||
<key>CFBundleURLTypes</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleURLName</key>
|
|
||||||
<string>REVERSED_CLIENT_ID</string>
|
|
||||||
<key>CFBundleURLSchemes</key>
|
|
||||||
<array>
|
|
||||||
<string>com.googleusercontent.apps.521527250907-3i1qe2656eojs8k9hjdi573j09i9p41m</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
10
ios/Runner/Runner.entitlements
Normal file
10
ios/Runner/Runner.entitlements
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.developer.applesignin</key>
|
||||||
|
<array>
|
||||||
|
<string>Default</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -3,60 +3,64 @@ import 'package:google_sign_in_platform_interface/google_sign_in_platform_interf
|
|||||||
import 'package:travel_mate/services/error_service.dart';
|
import 'package:travel_mate/services/error_service.dart';
|
||||||
|
|
||||||
/// Service for handling Firebase authentication operations.
|
/// Service for handling Firebase authentication operations.
|
||||||
///
|
///
|
||||||
/// This service provides methods for user authentication including email/password
|
/// This service provides methods for user authentication including email/password
|
||||||
/// sign-in, Google sign-in, Apple sign-in, password reset, and account management.
|
/// sign-in, Google sign-in, Apple sign-in, password reset, and account management.
|
||||||
/// It acts as a wrapper around Firebase Auth functionality.
|
/// It acts as a wrapper around Firebase Auth functionality.
|
||||||
class AuthService {
|
class AuthService {
|
||||||
/// Error service for logging authentication errors.
|
/// Error service for logging authentication errors.
|
||||||
final _errorService = ErrorService();
|
final _errorService = ErrorService();
|
||||||
|
|
||||||
/// Firebase Auth instance for authentication operations.
|
/// Firebase Auth instance for authentication operations.
|
||||||
final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
|
final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
|
||||||
|
|
||||||
/// Gets the currently authenticated user.
|
/// Gets the currently authenticated user.
|
||||||
///
|
///
|
||||||
/// Returns null if no user is currently signed in.
|
/// Returns null if no user is currently signed in.
|
||||||
User? get currentUser => firebaseAuth.currentUser;
|
User? get currentUser => firebaseAuth.currentUser;
|
||||||
|
|
||||||
/// Stream that emits authentication state changes.
|
/// Stream that emits authentication state changes.
|
||||||
///
|
///
|
||||||
/// Emits the current user when authenticated, null when not authenticated.
|
/// Emits the current user when authenticated, null when not authenticated.
|
||||||
Stream<User?> get authStateChanges => firebaseAuth.authStateChanges();
|
Stream<User?> get authStateChanges => firebaseAuth.authStateChanges();
|
||||||
|
|
||||||
/// Signs in a user with email and password.
|
/// Signs in a user with email and password.
|
||||||
///
|
///
|
||||||
/// Returns a [UserCredential] containing the authenticated user's information.
|
/// Returns a [UserCredential] containing the authenticated user's information.
|
||||||
/// Throws [FirebaseAuthException] if authentication fails.
|
/// Throws [FirebaseAuthException] if authentication fails.
|
||||||
Future<UserCredential> signInWithEmailAndPassword({
|
Future<UserCredential> signInWithEmailAndPassword({
|
||||||
required String email,
|
required String email,
|
||||||
required String password
|
required String password,
|
||||||
}) async {
|
}) async {
|
||||||
return await firebaseAuth.signInWithEmailAndPassword(
|
return await firebaseAuth.signInWithEmailAndPassword(
|
||||||
email: email, password: password);
|
email: email,
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new user account with email and password.
|
/// Creates a new user account with email and password.
|
||||||
///
|
///
|
||||||
/// Returns a [UserCredential] containing the new user's information.
|
/// Returns a [UserCredential] containing the new user's information.
|
||||||
/// Throws [FirebaseAuthException] if account creation fails.
|
/// Throws [FirebaseAuthException] if account creation fails.
|
||||||
Future<UserCredential> signUpWithEmailAndPassword({
|
Future<UserCredential> signUpWithEmailAndPassword({
|
||||||
required String email,
|
required String email,
|
||||||
required String password
|
required String password,
|
||||||
}) async {
|
}) async {
|
||||||
return await firebaseAuth.createUserWithEmailAndPassword(
|
return await firebaseAuth.createUserWithEmailAndPassword(
|
||||||
email: email, password: password);
|
email: email,
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signs out the current user.
|
/// Signs out the current user.
|
||||||
///
|
///
|
||||||
/// Clears the authentication state and signs out the user from Firebase.
|
/// Clears the authentication state and signs out the user from Firebase.
|
||||||
Future<void> signOut() async {
|
Future<void> signOut() async {
|
||||||
await firebaseAuth.signOut();
|
await firebaseAuth.signOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a password reset email to the specified email address.
|
/// Sends a password reset email to the specified email address.
|
||||||
///
|
///
|
||||||
/// The user will receive an email with instructions to reset their password.
|
/// The user will receive an email with instructions to reset their password.
|
||||||
/// Throws [FirebaseAuthException] if the email is invalid or other errors occur.
|
/// Throws [FirebaseAuthException] if the email is invalid or other errors occur.
|
||||||
Future<void> resetPassword(String email) async {
|
Future<void> resetPassword(String email) async {
|
||||||
@@ -64,20 +68,18 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the display name of the current user.
|
/// Updates the display name of the current user.
|
||||||
///
|
///
|
||||||
/// Requires a user to be currently authenticated.
|
/// Requires a user to be currently authenticated.
|
||||||
/// Throws if no user is signed in.
|
/// Throws if no user is signed in.
|
||||||
Future<void> updateDisplayName({
|
Future<void> updateDisplayName({required String displayName}) async {
|
||||||
required String displayName,
|
|
||||||
}) async {
|
|
||||||
await currentUser!.updateDisplayName(displayName);
|
await currentUser!.updateDisplayName(displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes the current user's account permanently.
|
/// Deletes the current user's account permanently.
|
||||||
///
|
///
|
||||||
/// Requires re-authentication with the user's current password for security.
|
/// Requires re-authentication with the user's current password for security.
|
||||||
/// This operation cannot be undone.
|
/// This operation cannot be undone.
|
||||||
///
|
///
|
||||||
/// [password] - The user's current password for re-authentication
|
/// [password] - The user's current password for re-authentication
|
||||||
/// [email] - The user's email address for re-authentication
|
/// [email] - The user's email address for re-authentication
|
||||||
Future<void> deleteAccount({
|
Future<void> deleteAccount({
|
||||||
@@ -85,8 +87,10 @@ class AuthService {
|
|||||||
required String email,
|
required String email,
|
||||||
}) async {
|
}) async {
|
||||||
// Re-authenticate the user for security
|
// Re-authenticate the user for security
|
||||||
AuthCredential credential =
|
AuthCredential credential = EmailAuthProvider.credential(
|
||||||
EmailAuthProvider.credential(email: email, password: password);
|
email: email,
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
await currentUser!.reauthenticateWithCredential(credential);
|
await currentUser!.reauthenticateWithCredential(credential);
|
||||||
|
|
||||||
// Delete the user account permanently
|
// Delete the user account permanently
|
||||||
@@ -95,10 +99,10 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Resets the user's password after re-authentication.
|
/// Resets the user's password after re-authentication.
|
||||||
///
|
///
|
||||||
/// This method allows users to change their password by providing their
|
/// This method allows users to change their password by providing their
|
||||||
/// current password for security verification.
|
/// current password for security verification.
|
||||||
///
|
///
|
||||||
/// [currentPassword] - The user's current password for verification
|
/// [currentPassword] - The user's current password for verification
|
||||||
/// [newPassword] - The new password to set
|
/// [newPassword] - The new password to set
|
||||||
/// [email] - The user's email address for re-authentication
|
/// [email] - The user's email address for re-authentication
|
||||||
@@ -108,8 +112,10 @@ class AuthService {
|
|||||||
required String email,
|
required String email,
|
||||||
}) async {
|
}) async {
|
||||||
// Re-authenticate the user for security
|
// Re-authenticate the user for security
|
||||||
AuthCredential credential =
|
AuthCredential credential = EmailAuthProvider.credential(
|
||||||
EmailAuthProvider.credential(email: email, password: currentPassword);
|
email: email,
|
||||||
|
password: currentPassword,
|
||||||
|
);
|
||||||
await currentUser!.reauthenticateWithCredential(credential);
|
await currentUser!.reauthenticateWithCredential(credential);
|
||||||
|
|
||||||
// Update to the new password
|
// Update to the new password
|
||||||
@@ -117,23 +123,24 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Ensures Google Sign-In is properly initialized.
|
/// Ensures Google Sign-In is properly initialized.
|
||||||
///
|
///
|
||||||
/// This method must be called before attempting Google authentication.
|
/// This method must be called before attempting Google authentication.
|
||||||
Future<void> ensureInitialized(){
|
Future<void> ensureInitialized() {
|
||||||
return GoogleSignInPlatform.instance.init(const InitParameters());
|
return GoogleSignInPlatform.instance.init(const InitParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signs in a user using Google authentication.
|
/// Signs in a user using Google authentication.
|
||||||
///
|
///
|
||||||
/// Handles the complete Google Sign-In flow including platform initialization
|
/// Handles the complete Google Sign-In flow including platform initialization
|
||||||
/// and credential exchange with Firebase.
|
/// and credential exchange with Firebase.
|
||||||
///
|
///
|
||||||
/// Returns a [UserCredential] containing the authenticated user's information.
|
/// Returns a [UserCredential] containing the authenticated user's information.
|
||||||
/// Throws various exceptions if authentication fails.
|
/// Throws various exceptions if authentication fails.
|
||||||
Future<UserCredential> signInWithGoogle() async {
|
Future<UserCredential> signInWithGoogle() async {
|
||||||
try {
|
try {
|
||||||
await ensureInitialized();
|
await ensureInitialized();
|
||||||
final AuthenticationResults result = await GoogleSignInPlatform.instance.authenticate(const AuthenticateParameters());
|
final AuthenticationResults result = await GoogleSignInPlatform.instance
|
||||||
|
.authenticate(const AuthenticateParameters());
|
||||||
final String? idToken = result.authenticationTokens.idToken;
|
final String? idToken = result.authenticationTokens.idToken;
|
||||||
if (idToken == null) {
|
if (idToken == null) {
|
||||||
throw FirebaseAuthException(
|
throw FirebaseAuthException(
|
||||||
@@ -141,31 +148,38 @@ class AuthService {
|
|||||||
message: 'Missing Google ID Token',
|
message: 'Missing Google ID Token',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final OAuthCredential credential = GoogleAuthProvider.credential(idToken: idToken);
|
final OAuthCredential credential = GoogleAuthProvider.credential(
|
||||||
UserCredential userCredential = await firebaseAuth.signInWithCredential(credential);
|
idToken: idToken,
|
||||||
|
);
|
||||||
|
UserCredential userCredential = await firebaseAuth.signInWithCredential(
|
||||||
|
credential,
|
||||||
|
);
|
||||||
|
|
||||||
// Return the UserCredential instead of void
|
// Return the UserCredential instead of void
|
||||||
return userCredential;
|
return userCredential;
|
||||||
}
|
}
|
||||||
|
|
||||||
} on GoogleSignInException catch (e) {
|
} on GoogleSignInException catch (e) {
|
||||||
_errorService.logError('Google Sign-In error: $e', StackTrace.current);
|
_errorService.logError('Google Sign-In error: $e', StackTrace.current);
|
||||||
rethrow;
|
rethrow;
|
||||||
} on FirebaseAuthException catch (e) {
|
} on FirebaseAuthException catch (e) {
|
||||||
_errorService.logError('Firebase error during Google Sign-In initialization: $e', StackTrace.current);
|
_errorService.logError(
|
||||||
|
'Firebase error during Google Sign-In initialization: $e',
|
||||||
|
StackTrace.current,
|
||||||
|
);
|
||||||
rethrow;
|
rethrow;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_errorService.logError('Unknown error during Google Sign-In initialization: $e', StackTrace.current);
|
_errorService.logError(
|
||||||
|
'Unknown error during Google Sign-In initialization: $e',
|
||||||
|
StackTrace.current,
|
||||||
|
);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Signs in a user using Apple authentication.
|
/// Signs in a user using Apple authentication.
|
||||||
///
|
///
|
||||||
/// TODO: Implement Apple Sign-In functionality
|
|
||||||
/// This method is currently a placeholder for future Apple authentication support.
|
/// This method is currently a placeholder for future Apple authentication support.
|
||||||
Future signInWithApple() async {
|
Future signInWithApple() async {
|
||||||
// TODO: Implement Apple sign-in
|
// TODO: Implement Apple sign-in
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user