Skip to content

Commit bc08550

Browse files
authored
Clean up FIRAuth bits from FIRApp (#2110)
* Clean up FIRAuth bits from FIRApp
1 parent 87a206e commit bc08550

File tree

6 files changed

+7
-160
lines changed

6 files changed

+7
-160
lines changed

Example/Auth/Tests/FIRAuthTests.m

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,6 @@ - (void)testLifeCycle {
365365
XCTAssertNil(auth);
366366
}
367367

368-
/** @fn testGetUID
369-
@brief Verifies that FIRApp's getUIDImplementation is correctly set by FIRAuth.
370-
*/
371-
- (void)testGetUID {
372-
// TODO: Remove this test once Firestore, Database, and Storage move over to the new Auth interop
373-
// library.
374-
FIRApp *app = [FIRApp defaultApp];
375-
XCTAssertNotNil(app.getUIDImplementation);
376-
[[FIRAuth auth] signOut:NULL];
377-
XCTAssertNil(app.getUIDImplementation());
378-
[self waitForSignIn];
379-
XCTAssertEqualObjects(app.getUIDImplementation(), kLocalID);
380-
}
381-
382368
#pragma mark - Server API Tests
383369

384370
/** @fn testFetchProvidersForEmailSuccess
@@ -2283,8 +2269,8 @@ - (void)mockSecureTokenResponseWithError:(nullable NSError *)error {
22832269
*/
22842270
- (void)enableAutoTokenRefresh {
22852271
XCTestExpectation *expectation = [self expectationWithDescription:@"autoTokenRefreshcallback"];
2286-
[[FIRAuth auth].app getTokenForcingRefresh:NO withCallback:^(NSString *_Nullable token,
2287-
NSError *_Nullable error) {
2272+
[[FIRAuth auth] getTokenForcingRefresh:NO withCallback:^(NSString *_Nullable token,
2273+
NSError *_Nullable error) {
22882274
[expectation fulfill];
22892275
}];
22902276
[self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];

Example/Core/Tests/FIRAppTest.m

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -267,59 +267,6 @@ - (void)testErrorForSubspecConfigurationFailure {
267267
XCTAssert([error.description containsString:@"Configuration failed for"]);
268268
}
269269

270-
- (void)testGetTokenWithCallback {
271-
[FIRApp configure];
272-
FIRApp *app = [FIRApp defaultApp];
273-
274-
__block BOOL getTokenImplementationWasCalled = NO;
275-
__block BOOL getTokenCallbackWasCalled = NO;
276-
__block BOOL passedRefreshValue = NO;
277-
278-
[app getTokenForcingRefresh:YES
279-
withCallback:^(NSString *_Nullable token, NSError *_Nullable error) {
280-
getTokenCallbackWasCalled = YES;
281-
}];
282-
283-
XCTAssert(getTokenCallbackWasCalled,
284-
@"The callback should be invoked by the base implementation when no block for "
285-
"'getTokenImplementation' has been specified.");
286-
287-
getTokenCallbackWasCalled = NO;
288-
289-
app.getTokenImplementation = ^(BOOL refresh, FIRTokenCallback callback) {
290-
getTokenImplementationWasCalled = YES;
291-
passedRefreshValue = refresh;
292-
callback(nil, nil);
293-
};
294-
[app getTokenForcingRefresh:YES
295-
withCallback:^(NSString *_Nullable token, NSError *_Nullable error) {
296-
getTokenCallbackWasCalled = YES;
297-
}];
298-
299-
XCTAssert(getTokenImplementationWasCalled,
300-
@"The 'getTokenImplementation' block was never called.");
301-
XCTAssert(passedRefreshValue,
302-
@"The value for the 'refresh' parameter wasn't passed to the 'getTokenImplementation' "
303-
"block correctly.");
304-
XCTAssert(getTokenCallbackWasCalled,
305-
@"The 'getTokenImplementation' should have invoked the callback. This could be an "
306-
"error in this test, or the callback parameter may not have been passed to the "
307-
"implementation correctly.");
308-
309-
getTokenImplementationWasCalled = NO;
310-
getTokenCallbackWasCalled = NO;
311-
passedRefreshValue = NO;
312-
313-
[app getTokenForcingRefresh:NO
314-
withCallback:^(NSString *_Nullable token, NSError *_Nullable error) {
315-
getTokenCallbackWasCalled = YES;
316-
}];
317-
318-
XCTAssertFalse(passedRefreshValue,
319-
@"The value for the 'refresh' parameter wasn't passed to the "
320-
"'getTokenImplementation' block correctly.");
321-
}
322-
323270
- (void)testOptionsLocking {
324271
FIROptions *options =
325272
[[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID];
@@ -754,16 +701,6 @@ - (void)testAnalyticsNotSetByGlobalDataCollectionSwitch {
754701

755702
#pragma mark - Internal Methods
756703

757-
// TODO: Remove this test once the `getUIDImplementation` block doesn't need to be set in Core.
758-
- (void)testAuthGetUID {
759-
[FIRApp configure];
760-
761-
[FIRApp defaultApp].getUIDImplementation = ^NSString * {
762-
return @"highlander";
763-
};
764-
XCTAssertEqual([[FIRApp defaultApp] getUID], @"highlander");
765-
}
766-
767704
- (void)testIsDefaultAppConfigured {
768705
// Ensure it's false before anything is configured.
769706
XCTAssertFalse([FIRApp isDefaultAppConfigured]);

Firebase/Auth/Source/FIRAuth.m

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#import <UIKit/UIKit.h>
2323
#endif
2424

25-
#import <FirebaseAuthInterop/FIRAuthInterop.h>
2625
#import <FirebaseCore/FIRAppAssociationRegistration.h>
2726
#import <FirebaseCore/FIRAppInternal.h>
2827
#import <FirebaseCore/FIRComponent.h>
@@ -229,9 +228,9 @@ + (FIRActionCodeOperation)actionCodeOperationForRequestType:(NSString *)requestT
229228
#pragma mark - FIRAuth
230229

231230
#if TARGET_OS_IOS
232-
@interface FIRAuth () <FIRAuthAppDelegateHandler, FIRAuthInterop, FIRComponentRegistrant, FIRCoreConfigurable, FIRComponentLifecycleMaintainer>
231+
@interface FIRAuth () <FIRAuthAppDelegateHandler, FIRComponentRegistrant, FIRCoreConfigurable, FIRComponentLifecycleMaintainer>
233232
#else
234-
@interface FIRAuth () <FIRAuthInterop, FIRComponentRegistrant, FIRCoreConfigurable, FIRComponentLifecycleMaintainer>
233+
@interface FIRAuth () <FIRComponentRegistrant, FIRCoreConfigurable, FIRComponentLifecycleMaintainer>
235234
#endif
236235

237236
/** @property firebaseAppId
@@ -344,23 +343,6 @@ - (instancetype)initWithApp:(FIRApp *)app {
344343
self = [self initWithAPIKey:app.options.APIKey appName:app.name];
345344
if (self) {
346345
_app = app;
347-
__weak FIRAuth *weakSelf = self;
348-
349-
// TODO: Remove this block once Firestore, Database, and Storage move to the new interop API.
350-
app.getTokenImplementation = ^(BOOL forceRefresh, FIRTokenCallback callback) {
351-
// In the meantime, redirect call to the interop method that provides this functionality.
352-
__weak FIRAuth *weakSelf = self;
353-
[weakSelf getTokenForcingRefresh:forceRefresh withCallback:callback];
354-
};
355-
356-
// TODO: Remove this block once Firestore, Database, and Storage move to the new interop API.
357-
app.getUIDImplementation = ^NSString *_Nullable() {
358-
__block NSString *uid;
359-
dispatch_sync(FIRAuthGlobalWorkQueue(), ^{
360-
uid = [weakSelf getUserID];
361-
});
362-
return uid;
363-
};
364346
#if TARGET_OS_IOS
365347
_authURLPresenter = [[FIRAuthURLPresenter alloc] init];
366348
#endif

Firebase/Auth/Source/FIRAuth_Internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#import "FIRAuth.h"
2020

21+
#import <FirebaseAuthInterop/FIRAuthInterop.h>
22+
2123
@class FIRAuthRequestConfiguration;
2224

2325
#if TARGET_OS_IOS
@@ -29,7 +31,7 @@
2931

3032
NS_ASSUME_NONNULL_BEGIN
3133

32-
@interface FIRAuth ()
34+
@interface FIRAuth () <FIRAuthInterop>
3335

3436
/** @property requestConfiguration
3537
@brief The configuration object comprising of paramters needed to make a request to Firebase

Firebase/Core/FIRApp.m

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,6 @@ - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)opti
281281
return self;
282282
}
283283

284-
- (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback)callback {
285-
if (!_getTokenImplementation) {
286-
callback(nil, nil);
287-
return;
288-
}
289-
290-
_getTokenImplementation(forceRefresh, callback);
291-
}
292-
293284
- (BOOL)configureCore {
294285
[self checkExpectedBundleID];
295286
if (![self isAppIDValid]) {
@@ -538,15 +529,6 @@ - (void)checkExpectedBundleID {
538529
}
539530
}
540531

541-
// TODO: Remove once SDKs transition to Auth interop library.
542-
- (nullable NSString *)getUID {
543-
if (!_getUIDImplementation) {
544-
FIRLogWarning(kFIRLoggerCore, @"I-COR000025", @"FIRAuth getUID implementation wasn't set.");
545-
return nil;
546-
}
547-
return _getUIDImplementation();
548-
}
549-
550532
#pragma mark - private - App ID Validation
551533

552534
/**

Firebase/Core/Private/FIRAppInternal.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -109,42 +109,13 @@ extern NSString *const FIRAuthStateDidChangeInternalNotificationAppKey;
109109
*/
110110
extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
111111

112-
/** @typedef FIRTokenCallback
113-
@brief The type of block which gets called when a token is ready.
114-
*/
115-
typedef void (^FIRTokenCallback)(NSString *_Nullable token, NSError *_Nullable error);
116-
117-
/** @typedef FIRAppGetTokenImplementation
118-
@brief The type of block which can provide an implementation for the @c getTokenWithCallback:
119-
method.
120-
@param forceRefresh Forces the token to be refreshed.
121-
@param callback The block which should be invoked when the async call completes.
122-
*/
123-
typedef void (^FIRAppGetTokenImplementation)(BOOL forceRefresh, FIRTokenCallback callback);
124-
125-
/** @typedef FIRAppGetUID
126-
@brief The type of block which can provide an implementation for the @c getUID method.
127-
*/
128-
typedef NSString *_Nullable (^FIRAppGetUIDImplementation)(void);
129-
130112
@interface FIRApp ()
131113

132114
/**
133115
* A flag indicating if this is the default app (has the default app name).
134116
*/
135117
@property(nonatomic, readonly) BOOL isDefaultApp;
136118

137-
/** @property getTokenImplementation
138-
@brief Gets or sets the block to use for the implementation of
139-
@c getTokenForcingRefresh:withCallback:
140-
*/
141-
@property(nonatomic, copy) FIRAppGetTokenImplementation getTokenImplementation;
142-
143-
/** @property getUIDImplementation
144-
@brief Gets or sets the block to use for the implementation of @c getUID.
145-
*/
146-
@property(nonatomic, copy) FIRAppGetUIDImplementation getUIDImplementation;
147-
148119
/*
149120
* The container of interop SDKs for this app.
150121
*/
@@ -204,19 +175,6 @@ typedef NSString *_Nullable (^FIRAppGetUIDImplementation)(void);
204175
*/
205176
- (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
206177

207-
/** @fn getTokenForcingRefresh:withCallback:
208-
@brief Retrieves the Firebase authentication token, possibly refreshing it.
209-
@param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
210-
other than an expiration.
211-
@param callback The block to invoke when the token is available.
212-
*/
213-
- (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback)callback;
214-
215-
/**
216-
* Expose the UID of the current user for Firestore.
217-
*/
218-
- (nullable NSString *)getUID;
219-
220178
@end
221179

222180
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)