Skip to content

Commit 7598ba7

Browse files
committed
AuthUser -> Swift (#10993)
1 parent 0d9eebe commit 7598ba7

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.
@@ -586,6 +588,10 @@ - (nullable FIRUser *)currentUser {
586588
return result;
587589
}
588590

591+
- (nullable FIRUser *)rawCurrentUser {
592+
return self->_currentUser;
593+
}
594+
589595
- (void)signInWithProvider:(id<FIRFederatedAuthProvider>)provider
590596
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
591597
completion:(nullable FIRAuthDataResultCallback)completion {
@@ -931,7 +937,7 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
931937
}
932938

933939
[self
934-
completeSignInWithAccessToken:response.idToken
940+
completeSignInWithAccessToken:response.IDToken
935941
accessTokenExpirationDate:response.approximateExpirationDate
936942
refreshToken:response.refreshToken
937943
anonymous:NO
@@ -1001,7 +1007,7 @@ - (void)internalSignInAndRetrieveDataWithCredential:(FIRAuthCredential *)credent
10011007
return;
10021008
}
10031009
[self
1004-
completeSignInWithAccessToken:response.idToken
1010+
completeSignInWithAccessToken:response.IDToken
10051011
accessTokenExpirationDate:response.approximateExpirationDate
10061012
refreshToken:response.refreshToken
10071013
anonymous:NO
@@ -1035,7 +1041,7 @@ - (void)signInAnonymouslyWithCompletion:(nullable FIRAuthDataResultCallback)comp
10351041
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
10361042
FIRAuthDataResultCallback decoratedCallback =
10371043
[self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
1038-
if (self->_currentUser.anonymous) {
1044+
if (self->_currentUser.isAnonymous) {
10391045
FIRAuthDataResult *result = [[FIRAuthDataResult alloc] initWithUser:self->_currentUser
10401046
additionalUserInfo:nil
10411047
credential:nil];
@@ -1672,7 +1678,7 @@ - (void)internalSignInAndRetrieveDataWithCustomToken:(NSString *)token
16721678
return;
16731679
}
16741680
}
1675-
[self completeSignInWithAccessToken:response.idToken
1681+
[self completeSignInWithAccessToken:response.IDToken
16761682
accessTokenExpirationDate:response.approximateExpirationDate
16771683
refreshToken:response.refreshToken
16781684
anonymous:NO
@@ -1771,19 +1777,6 @@ - (void)possiblyPostAuthStateChangeNotification {
17711777
});
17721778
}
17731779

1774-
- (BOOL)updateKeychainWithUser:(FIRUser *)user error:(NSError *_Nullable *_Nullable)error {
1775-
if (user != _currentUser) {
1776-
// No-op if the user is no longer signed in. This is not considered an error as we don't check
1777-
// whether the user is still current on other callbacks of user operations either.
1778-
return YES;
1779-
}
1780-
if ([self saveUser:user error:error]) {
1781-
[self possiblyPostAuthStateChangeNotification];
1782-
return YES;
1783-
}
1784-
return NO;
1785-
}
1786-
17871780
+ (NSString *)keychainServiceNameForAppID:(NSString *)appID {
17881781
return [@"firebase_auth_" stringByAppendingString:appID];
17891782
}

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)