Skip to content

Commit

Permalink
Remove deprecated auth APIs (#6607)
Browse files Browse the repository at this point in the history
* Remove deprecated APIs from public header.

* Remove deprecated API implementations.

* Also remove deprecated APIs from FIRUser.

* Update unit tests.

* Update sample app.

* Update changelog.
  • Loading branch information
rosalyntan committed Sep 30, 2020
1 parent fa9c24a commit 14764b8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 218 deletions.
3 changes: 3 additions & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- [removed] Remove deprecated APIs `dataForKey`,`fetchProvidersForEmail:completion`, `signInAndRetrieveDataWithCredential:completion`, `reauthenticateAndRetrieveDataWithCredential:completion`, `linkAndRetrieveDataWithCredential:completion`. (#6607)

# v6.9.1
- [fixed] Internal source documentation. (#6371)

Expand Down
36 changes: 0 additions & 36 deletions FirebaseAuth/Sources/Auth/FIRAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,6 @@ @interface FIRActionCodeInfo ()

@implementation FIRActionCodeInfo

- (NSString *)dataForKey:(FIRActionDataKey)key {
switch (key) {
case FIRActionCodeEmailKey:
return self.email;
case FIRActionCodeFromEmailKey:
return self.previousEmail;
}
}

- (instancetype)initWithOperation:(FIRActionCodeOperation)operation
email:(NSString *)email
newEmail:(nullable NSString *)newEmail {
Expand Down Expand Up @@ -589,25 +580,6 @@ - (nullable FIRUser *)currentUser {
return result;
}

- (void)fetchProvidersForEmail:(NSString *)email
completion:(nullable FIRProviderQueryCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
FIRCreateAuthURIRequest *request =
[[FIRCreateAuthURIRequest alloc] initWithIdentifier:email
continueURI:@"http://www.google.com/"
requestConfiguration:self->_requestConfiguration];
[FIRAuthBackend
createAuthURI:request
callback:^(FIRCreateAuthURIResponse *_Nullable response, NSError *_Nullable error) {
if (completion) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(response.allProviders, error);
});
}
}];
});
}

- (void)signInWithProvider:(id<FIRFederatedAuthProvider>)provider
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
completion:(nullable FIRAuthDataResultCallback)completion {
Expand Down Expand Up @@ -858,16 +830,8 @@ - (void)internalSignInAndRetrieveDataWithEmail:(nonnull NSString *)email
}];
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)signInWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion {
[self signInAndRetrieveDataWithCredential:credential completion:completion];
}
#pragma clang diagnostic pop

- (void)signInAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
FIRAuthDataResultCallback callback =
[self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
Expand Down
40 changes: 0 additions & 40 deletions FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,6 @@ typedef void (^FIRApplyActionCodeCallback)(NSError *_Nullable error)

typedef void (^FIRAuthVoidErrorCallback)(NSError *_Nullable) NS_SWIFT_NAME(AuthVoidErrorCallback);

/**
@brief Deprecated. Please directly use email or previousEmail properties instead.
*/
typedef NS_ENUM(NSInteger, FIRActionDataKey) {
/** Deprecated. Please directly use email property instead. */
FIRActionCodeEmailKey = 0,

/** Deprecated. Please directly use previousEmail property instead. */
FIRActionCodeFromEmailKey = 1,

} NS_SWIFT_NAME(ActionDataKey)
DEPRECATED_MSG_ATTRIBUTE("Please directly use email or previousEmail properties instead.");

/** @class FIRActionCodeInfo
@brief Manages information regarding action codes.
*/
Expand Down Expand Up @@ -227,12 +214,6 @@ typedef NS_ENUM(NSInteger, FIRActionCodeOperation) {
*/
@property(nonatomic, readonly) FIRActionCodeOperation operation;

/** @fn dataForKey:
@brief Deprecated. Please directly use email or previousEmail properties instead.
*/
- (NSString *)dataForKey:(FIRActionDataKey)key
DEPRECATED_MSG_ATTRIBUTE("Please directly use email or previousEmail properties instead.");

/** @property email
@brief The email address to which the code was sent. The new email address in the case of
FIRActionCodeOperationRecoverEmail.
Expand Down Expand Up @@ -388,16 +369,6 @@ NS_SWIFT_NAME(Auth)
- (void)updateCurrentUser:(FIRUser *)user
completion:(nullable void (^)(NSError *_Nullable error))completion;

/** @fn fetchProvidersForEmail:completion:
@brief Please use fetchSignInMethodsForEmail:completion: for Objective-C or
fetchSignInMethods(forEmail:completion:) for Swift instead.
*/
- (void)fetchProvidersForEmail:(NSString *)email
completion:(nullable void (^)(NSArray<NSString *> *_Nullable providers,
NSError *_Nullable error))completion
DEPRECATED_MSG_ATTRIBUTE("Please use fetchSignInMethodsForEmail:completion: for Objective-C or "
"fetchSignInMethods(forEmail:completion:) for Swift instead.");

/** @fn fetchSignInMethodsForEmail:completion:
@brief Fetches the list of all sign-in methods previously used for the provided email address.
Expand Down Expand Up @@ -519,17 +490,6 @@ NS_SWIFT_NAME(Auth)
NSError *_Nullable error))completion
API_UNAVAILABLE(watchos);

/** @fn signInAndRetrieveDataWithCredential:completion:
@brief Please use signInWithCredential:completion: for Objective-C or "
"signIn(with:completion:) for Swift instead.
*/
- (void)signInAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:
(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error))completion
DEPRECATED_MSG_ATTRIBUTE("Please use signInWithCredential:completion: for Objective-C or "
"signIn(with:completion:) for Swift instead.");

/** @fn signInWithCredential:completion:
@brief Asynchronously signs in to Firebase with the given 3rd-party credentials (e.g. a Facebook
login Access Token, a Google ID Token/Access Token pair, etc.) and returns additional
Expand Down
23 changes: 0 additions & 23 deletions FirebaseAuth/Sources/Public/FirebaseAuth/FIRUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,6 @@ NS_SWIFT_NAME(User)
completion:(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error))completion;

/** @fn reauthenticateAndRetrieveDataWithCredential:completion:
@brief Please use linkWithCredential:completion: for Objective-C
or link(withCredential:completion:) for Swift instead.
*/
- (void)reauthenticateAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:(nullable void (^)(
FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error))completion
DEPRECATED_MSG_ATTRIBUTE("Please use reauthenticateWithCredential:completion: for"
" Objective-C or reauthenticate(withCredential:completion:)"
" for Swift instead.");

/** @fn reauthenticateWithProvider:UIDelegate:completion:
@brief Renews the user's authentication using the provided auth provider instance.
Expand Down Expand Up @@ -362,17 +350,6 @@ NS_SWIFT_NAME(User)
completion:(nullable void (^)(NSString *_Nullable token,
NSError *_Nullable error))completion;

/** @fn linkAndRetrieveDataWithCredential:completion:
@brief Please use linkWithCredential:completion: for Objective-C
or link(withCredential:completion:) for Swift instead.
*/
- (void)linkAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:
(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error))completion
DEPRECATED_MSG_ATTRIBUTE("Please use linkWithCredential:completion: for Objective-C "
"or link(withCredential:completion:) for Swift instead.");

/** @fn linkWithCredential:completion:
@brief Associates a user account from a third-party identity provider with this user and
returns additional identity provider data.
Expand Down
16 changes: 0 additions & 16 deletions FirebaseAuth/Sources/User/FIRUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -787,16 +787,8 @@ - (void)reloadWithCompletion:(nullable FIRUserProfileChangeCallback)completion {

#pragma mark -

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)reauthenticateWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion {
[self reauthenticateAndRetrieveDataWithCredential:credential completion:completion];
}
#pragma clang diagnostic pop

- (void)reauthenticateAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
[self->_auth
internalSignInAndRetrieveDataWithCredential:credential
Expand Down Expand Up @@ -1056,16 +1048,8 @@ - (void)internalVerifyBeforeUpdateEmailWithNewEmail:(NSString *)newEmail
});
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)linkWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion {
[self linkAndRetrieveDataWithCredential:credential completion:completion];
}
#pragma clang diagnostic pop

- (void)linkAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
if (self->_providerData[credential.provider]) {
callInMainThreadWithAuthDataResultAndError(completion, nil,
Expand Down
29 changes: 0 additions & 29 deletions FirebaseAuth/Tests/Sample/Sample/MainViewController+User.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ - (StaticContentTableViewSection *)userSection {
action:^{ [weakSelf updatePassword]; }],
[StaticContentTableViewCell cellWithTitle:@"Update Phone Number"
action:^{ [weakSelf updatePhoneNumber]; }],
[StaticContentTableViewCell cellWithTitle:@"Get Provider IDs for Email"
action:^{ [weakSelf getProvidersForEmail]; }],
[StaticContentTableViewCell cellWithTitle:@"Get Sign-in methods for Email"
action:^{ [weakSelf getAllSignInMethodsForEmail]; }],
[StaticContentTableViewCell cellWithTitle:@"Reload User"
Expand Down Expand Up @@ -112,33 +110,6 @@ - (void)reloadUser {
}];
}

- (void)getProvidersForEmail {
[self showTextInputPromptWithMessage:@"Email:"
completionBlock:^(BOOL userPressedOK, NSString *_Nullable userInput) {
if (!userPressedOK || !userInput.length) {
return;
}
[self showSpinner:^{
[[AppManager auth] fetchProvidersForEmail:userInput
completion:^(NSArray<NSString *> *_Nullable providers,
NSError *_Nullable error) {
if (error) {
[self logFailure:@"get providers for email failed" error:error];
} else {
[self logSuccess:@"get providers for email succeeded."];
}
[self hideSpinner:^{
if (error) {
[self showMessagePrompt:error.localizedDescription];
return;
}
[self showMessagePrompt:[providers componentsJoinedByString:@", "]];
}];
}];
}];
}];
}

- (void)getAllSignInMethodsForEmail {
[self showTextInputPromptWithMessage:@"Email:"
completionBlock:^(BOOL userPressedOK, NSString *_Nullable userInput) {
Expand Down
63 changes: 3 additions & 60 deletions FirebaseAuth/Tests/Unit/FIRAuthTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -378,39 +378,6 @@ - (void)tearDown {

#pragma mark - Server API Tests

/** @fn testFetchProvidersForEmailSuccess
@brief Tests the flow of a successful @c fetchProvidersForEmail:completion: call.
*/
- (void)testFetchProvidersForEmailSuccess {
NSArray<NSString *> *allProviders = @[ FIRGoogleAuthProviderID, FIREmailAuthProviderID ];
OCMExpect([_mockBackend createAuthURI:[OCMArg any] callback:[OCMArg any]])
.andCallBlock2(
^(FIRCreateAuthURIRequest *_Nullable request, FIRCreateAuthURIResponseCallback callback) {
XCTAssertEqualObjects(request.identifier, kEmail);
XCTAssertNotNil(request.endpoint);
XCTAssertEqualObjects(request.APIKey, kAPIKey);
dispatch_async(FIRAuthGlobalWorkQueue(), ^() {
id mockCreateAuthURIResponse = OCMClassMock([FIRCreateAuthURIResponse class]);
OCMStub([mockCreateAuthURIResponse allProviders]).andReturn(allProviders);
callback(mockCreateAuthURIResponse, nil);
});
});
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[FIRAuth auth]
fetchProvidersForEmail:kEmail
completion:^(NSArray<NSString *> *_Nullable providers, NSError *_Nullable error) {
#pragma clang diagnostic pop
XCTAssertTrue([NSThread isMainThread]);
XCTAssertEqualObjects(providers, allProviders);
XCTAssertNil(error);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];
OCMVerifyAll(_mockBackend);
}

/** @fn testFetchSignInMethodsForEmailSuccess
@brief Tests the flow of a successful @c fetchSignInMethodsForEmail:completion: call.
*/
Expand Down Expand Up @@ -443,30 +410,6 @@ - (void)testFetchSignInMethodsForEmailSuccess {
OCMVerifyAll(_mockBackend);
}

/** @fn testFetchProvidersForEmailFailure
@brief Tests the flow of a failed @c fetchProvidersForEmail:completion: call.
*/
- (void)testFetchProvidersForEmailFailure {
OCMExpect([_mockBackend createAuthURI:[OCMArg any] callback:[OCMArg any]])
.andDispatchError2([FIRAuthErrorUtils tooManyRequestsErrorWithMessage:nil]);
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[FIRAuth auth]
fetchProvidersForEmail:kEmail
completion:^(NSArray<NSString *> *_Nullable providers, NSError *_Nullable error) {

#pragma clang pop
XCTAssertTrue([NSThread isMainThread]);
XCTAssertNil(providers);
XCTAssertEqual(error.code, FIRAuthErrorCodeTooManyRequests);
XCTAssertNotNil(error.userInfo[NSLocalizedDescriptionKey]);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:kExpectationTimeout handler:nil];
OCMVerifyAll(_mockBackend);
}

/** @fn testFetchSignInMethodsForEmailFailure
@brief Tests the flow of a failed @c fetchSignInMethodsForEmail:completion: call.
*/
Expand Down Expand Up @@ -1363,11 +1306,11 @@ - (void)testSignInWithOAuthCredentialSuccess {
}
#endif // TARGET_OS_IOS

/** @fn testSignInAndRetrieveDataWithCredentialSuccess
@brief Tests the flow of a successful @c signInAndRetrieveDataWithCredential:completion: call
/** @fn testSignInWithCredentialSuccess
@brief Tests the flow of a successful @c signInWithCredential:completion: call
with an Google Sign-In credential.
*/
- (void)testSignInAndRetrieveDataWithCredentialSuccess {
- (void)testSignInWithCredentialSuccess {
OCMExpect([_mockBackend verifyAssertion:[OCMArg any] callback:[OCMArg any]])
.andCallBlock2(^(FIRVerifyAssertionRequest *_Nullable request,
FIRVerifyAssertionResponseCallback callback) {
Expand Down

0 comments on commit 14764b8

Please sign in to comment.