Skip to content

Commit e25ecfa

Browse files
committed
AuthUser -> Swift (#10993)
1 parent 755b878 commit e25ecfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2289
-2449
lines changed

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h"
3232
#import "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h"
3333
#import "FirebaseAuth/Sources/SystemService/FIRAuthStoredUserManager.h"
34-
#import "FirebaseAuth/Sources/User/FIRUser_Internal.h"
3534
#import "FirebaseAuth/Sources/Utilities/FIRAuthExceptionUtils.h"
3635

3736
#if TARGET_OS_IOS
@@ -302,7 +301,8 @@ @interface FIRAuth () <FIRLibrary, FIRComponentLifecycleMaintainer>
302301
/** @property storedUserManager
303302
@brief The stored user manager.
304303
*/
305-
@property(nonatomic, strong, nullable) FIRAuthStoredUserManager *storedUserManager;
304+
// TODO: temporary in FIRAuth.h
305+
//@property(nonatomic, strong, nullable) FIRAuthStoredUserManager *storedUserManager;
306306

307307
/** @fn initWithApp:
308308
@brief Creates a @c FIRAuth instance associated with the provided @c FIRApp instance.
@@ -321,7 +321,8 @@ @implementation FIRAuth {
321321
/** @var _firebaseAppName
322322
@brief The Firebase app name.
323323
*/
324-
NSString *_firebaseAppName;
324+
// TODO: temporary in FIRAuth.h
325+
// NSString *_firebaseAppName;
325326

326327
/** @var _listenerHandles
327328
@brief Handles returned from @c NSNotificationCenter for blocks which are "auth state did
@@ -333,7 +334,8 @@ @implementation FIRAuth {
333334
/** @var _keychainServices
334335
@brief The keychain service.
335336
*/
336-
id<FIRAuthStorage> _keychainServices;
337+
// TODO: temporary in FIRAuth.h
338+
// FIRAuthKeychainServices *_keychainServices;
337339

338340
/** @var _lastNotifiedUserToken
339341
@brief The user access (ID) token used last time for posting auth state changed notification.
@@ -599,6 +601,10 @@ - (nullable FIRUser *)currentUser {
599601
return result;
600602
}
601603

604+
- (nullable FIRUser *)rawCurrentUser {
605+
return self->_currentUser;
606+
}
607+
602608
- (void)signInWithProvider:(id<FIRFederatedAuthProvider>)provider
603609
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
604610
completion:(nullable FIRAuthDataResultCallback)completion {
@@ -944,7 +950,7 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
944950
}
945951

946952
[self
947-
completeSignInWithAccessToken:response.idToken
953+
completeSignInWithAccessToken:response.IDToken
948954
accessTokenExpirationDate:response.approximateExpirationDate
949955
refreshToken:response.refreshToken
950956
anonymous:NO
@@ -1014,7 +1020,7 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
10141020
return;
10151021
}
10161022
[self
1017-
completeSignInWithAccessToken:response.idToken
1023+
completeSignInWithAccessToken:response.IDToken
10181024
accessTokenExpirationDate:response.approximateExpirationDate
10191025
refreshToken:response.refreshToken
10201026
anonymous:NO
@@ -1048,7 +1054,7 @@ - (void)signInAnonymouslyWithCompletion:(nullable FIRAuthDataResultCallback)comp
10481054
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
10491055
FIRAuthDataResultCallback decoratedCallback =
10501056
[self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
1051-
if (self->_currentUser.anonymous) {
1057+
if (self->_currentUser.isAnonymous) {
10521058
FIRAuthDataResult *result = [[FIRAuthDataResult alloc] initWithUser:self->_currentUser
10531059
additionalUserInfo:nil
10541060
credential:nil];
@@ -1685,7 +1691,7 @@ - (void)internalSignInAndRetrieveDataWithCustomToken:(NSString *)token
16851691
return;
16861692
}
16871693
}
1688-
[self completeSignInWithAccessToken:response.idToken
1694+
[self completeSignInWithAccessToken:response.IDToken
16891695
accessTokenExpirationDate:response.approximateExpirationDate
16901696
refreshToken:response.refreshToken
16911697
anonymous:NO
@@ -1784,19 +1790,6 @@ - (void)possiblyPostAuthStateChangeNotification {
17841790
});
17851791
}
17861792

1787-
- (BOOL)updateKeychainWithUser:(FIRUser *)user error:(NSError *_Nullable *_Nullable)error {
1788-
if (user != _currentUser) {
1789-
// No-op if the user is no longer signed in. This is not considered an error as we don't check
1790-
// whether the user is still current on other callbacks of user operations either.
1791-
return YES;
1792-
}
1793-
if ([self saveUser:user error:error]) {
1794-
[self possiblyPostAuthStateChangeNotification];
1795-
return YES;
1796-
}
1797-
return NO;
1798-
}
1799-
18001793
+ (NSString *)keychainServiceNameForAppID:(NSString *)appID {
18011794
return [@"firebase_auth_" stringByAppendingString:appID];
18021795
}

FirebaseAuth/Sources/Auth/FIRAuth_Internal.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ NS_ASSUME_NONNULL_BEGIN
5353
*/
5454
- (nullable NSString *)getUserID;
5555

56-
/** @fn updateKeychainWithUser:error:
57-
@brief Updates the keychain for the given user.
58-
@param user The user to be updated.
59-
@param error The error caused the method to fail if the method returns NO.
60-
@return Whether updating keychain has succeeded or not.
61-
@remarks Called by @c FIRUser when user info or token changes occur.
62-
*/
63-
- (BOOL)updateKeychainWithUser:(FIRUser *)user error:(NSError *_Nullable *_Nullable)error;
64-
6556
/** @fn internalSignInWithCredential:callback:
6657
@brief Convenience method for @c internalSignInAndRetrieveDataWithCredential:callback:
6758
This method doesn't return additional identity provider data.

FirebaseAuth/Sources/MultiFactor/FIRMultiFactor+Internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
2323

2424
@interface FIRMultiFactor () <NSSecureCoding>
2525

26+
// TODO: revisit User.swift usage of this property after this is in Swift.
27+
2628
@property(nonatomic, weak) FIRUser *user;
2729

2830
/** @fn initWithMFAEnrollments:

FirebaseAuth/Sources/MultiFactor/FIRMultiFactor.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#import "FirebaseAuth/Sources/Auth/FIRAuth_Internal.h"
2222
#import "FirebaseAuth/Sources/MultiFactor/FIRMultiFactor+Internal.h"
23-
#import "FirebaseAuth/Sources/User/FIRUser_Internal.h"
2423

2524
#import "FirebaseAuth-Swift.h"
2625

@@ -49,7 +48,7 @@ - (void)enrollWithAssertion:(FIRMultiFactorAssertion *)assertion
4948
initWithSessionInfo:phoneAssertion.authCredential.verificationID
5049
verificationCode:phoneAssertion.authCredential.verificationCode];
5150
FIRFinalizeMFAEnrollmentRequest *request =
52-
[[FIRFinalizeMFAEnrollmentRequest alloc] initWithIDToken:self.user.rawAccessToken
51+
[[FIRFinalizeMFAEnrollmentRequest alloc] initWithIDToken:self.user.tokenService.accessToken
5352
displayName:displayName
5453
verificationInfo:finalizeMFAPhoneRequestInfo
5554
requestConfiguration:self.user.requestConfiguration];
@@ -97,7 +96,7 @@ - (void)unenrollWithInfo:(FIRMultiFactorInfo *)factorInfo
9796
- (void)unenrollWithFactorUID:(NSString *)factorUID
9897
completion:(nullable FIRAuthVoidErrorCallback)completion {
9998
FIRWithdrawMFARequest *request =
100-
[[FIRWithdrawMFARequest alloc] initWithIDToken:self.user.rawAccessToken
99+
[[FIRWithdrawMFARequest alloc] initWithIDToken:self.user.tokenService.accessToken
101100
MFAEnrollmentID:factorUID
102101
requestConfiguration:self.user.requestConfiguration];
103102
[FIRAuthBackend2

FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
@class FIRUser;
3131
@class FIRAuthNotificationManager;
3232
@class FIRAuthURLPresenter;
33+
@class FIRAuthKeychainServices;
34+
@class FIRAuthStoredUserManager;
3335
@protocol FIRAuthUIDelegate;
3436
@protocol FIRFederatedAuthProvider;
3537

@@ -312,6 +314,10 @@ NS_SWIFT_NAME(Auth)
312314
*/
313315
@property(nonatomic, strong, readonly) FIRAuthNotificationManager *notificationManager;
314316

317+
@property(nonatomic, strong) NSString *firebaseAppName;
318+
@property(nonatomic) FIRAuthKeychainServices *keychainServices;
319+
@property(nonatomic) FIRAuthStoredUserManager *storedUserManager;
320+
315321
// TODO: Temporary bridge from Swift until completely ported.
316322
+ (dispatch_queue_t)globalWorkQueue;
317323

@@ -340,6 +346,9 @@ NS_SWIFT_NAME(Auth)
340346
*/
341347
@property(nonatomic, strong, readonly, nullable) FIRUser *currentUser;
342348

349+
// TODO: temporary for updateKeychain check. Revisit with Auth.swift. Should not be public.
350+
@property(nonatomic, strong, readonly, nullable) FIRUser *rawCurrentUser;
351+
343352
/** @property languageCode
344353
@brief The current user language code. This property can be set to the app's current language by
345354
calling `useAppLanguage()`.

FirebaseAuth/Sources/Public/FirebaseAuth/FIRMultiFactor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ NS_SWIFT_NAME(MultiFactor) API_UNAVAILABLE(macos, tvos, watchos) @interface FIRM
8787
- (void)unenrollWithFactorUID:(NSString *)factorUID
8888
completion:(nullable void (^)(NSError *_Nullable error))completion;
8989

90+
// TODO: revisit User.swift usage of internal User property after this is in Swift.
91+
9092
@end
9193

9294
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)