aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Auth
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2018-04-25 06:49:59 -0700
committerGravatar Paul Beusterien <paulbeusterien@google.com>2018-04-25 06:49:59 -0700
commit0ae7d902d724be67d77d5dab1ad698a6ab4e3dfc (patch)
tree6082b2e32e07fa94858a6582820b5d8e38baff8d /Firebase/Auth
parent260557691fae8ba34e262f480c632ab63b5133ee (diff)
First pass of Auth breaking changes (#1123)
Diffstat (limited to 'Firebase/Auth')
-rw-r--r--Firebase/Auth/Source/FIRAuth.m38
-rw-r--r--Firebase/Auth/Source/Public/FIRAuth.h89
2 files changed, 94 insertions, 33 deletions
diff --git a/Firebase/Auth/Source/FIRAuth.m b/Firebase/Auth/Source/FIRAuth.m
index 1930957..5ec9a6f 100644
--- a/Firebase/Auth/Source/FIRAuth.m
+++ b/Firebase/Auth/Source/FIRAuth.m
@@ -551,15 +551,15 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
- (void)signInWithEmail:(NSString *)email
password:(NSString *)password
- completion:(FIRAuthResultCallback)completion {
+ completion:(FIRAuthDataResultCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
- FIRAuthResultCallback decoratedCallback =
- [self signInFlowAuthResultCallbackByDecoratingCallback:completion];
+ FIRAuthDataResultCallback decoratedCallback =
+ [self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
[self internalSignInAndRetrieveDataWithEmail:email
password:password
completion:^(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error) {
- decoratedCallback(authResult.user, error);
+ decoratedCallback(authResult, error);
}];
});
}
@@ -887,12 +887,14 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
});
}
-- (void)signInAnonymouslyWithCompletion:(FIRAuthResultCallback)completion {
+- (void)signInAnonymouslyWithCompletion:(FIRAuthDataResultCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
- FIRAuthResultCallback decoratedCallback =
- [self signInFlowAuthResultCallbackByDecoratingCallback:completion];
+ FIRAuthDataResultCallback decoratedCallback =
+ [self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
if (self->_currentUser.anonymous) {
- decoratedCallback(self->_currentUser, nil);
+ FIRAuthDataResult *result =
+ [[FIRAuthDataResult alloc] initWithUser:self->_currentUser additionalUserInfo:nil];
+ decoratedCallback(result, nil);
return;
}
[self internalSignInAnonymouslyWithCompletion:^(FIRSignUpNewUserResponse *_Nullable response,
@@ -905,20 +907,30 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
accessTokenExpirationDate:response.approximateExpirationDate
refreshToken:response.refreshToken
anonymous:YES
- callback:decoratedCallback];
+ callback:^(FIRUser * _Nullable user, NSError * _Nullable error) {
+ FIRAdditionalUserInfo *additionalUserInfo =
+ [[FIRAdditionalUserInfo alloc] initWithProviderID:FIREmailAuthProviderID
+ profile:nil
+ username:nil
+ isNewUser:YES];
+ FIRAuthDataResult *authDataResult =
+ [[FIRAuthDataResult alloc] initWithUser:user
+ additionalUserInfo:additionalUserInfo];
+ decoratedCallback(authDataResult, nil);
+ }];
}];
});
}
- (void)signInWithCustomToken:(NSString *)token
- completion:(nullable FIRAuthResultCallback)completion {
+ completion:(nullable FIRAuthDataResultCallback)completion {
dispatch_async(FIRAuthGlobalWorkQueue(), ^{
- FIRAuthResultCallback decoratedCallback =
- [self signInFlowAuthResultCallbackByDecoratingCallback:completion];
+ FIRAuthDataResultCallback decoratedCallback =
+ [self signInFlowAuthDataResultCallbackByDecoratingCallback:completion];
[self internalSignInAndRetrieveDataWithCustomToken:token
completion:^(FIRAuthDataResult *_Nullable authResult,
NSError *_Nullable error) {
- decoratedCallback(authResult.user, error);
+ decoratedCallback(authResult, error);
}];
});
}
diff --git a/Firebase/Auth/Source/Public/FIRAuth.h b/Firebase/Auth/Source/Public/FIRAuth.h
index 711e4b6..c20ecbe 100644
--- a/Firebase/Auth/Source/Public/FIRAuth.h
+++ b/Firebase/Auth/Source/Public/FIRAuth.h
@@ -370,7 +370,7 @@ NS_SWIFT_NAME(Auth)
*/
- (void)signInWithEmail:(NSString *)email
password:(NSString *)password
- completion:(nullable FIRAuthResultCallback)completion;
+ completion:(nullable FIRAuthDataResultCallback)completion;
/** @fn signInWithEmail:link:completion:
@brief Signs in using an email address and email sign-in link.
@@ -397,7 +397,8 @@ NS_SWIFT_NAME(Auth)
completion:(nullable FIRAuthDataResultCallback)completion;
/** @fn signInAndRetrieveDataWithEmail:password:completion:
- @brief Signs in using an email address and password.
+ @brief Please use `signInWithEmail:password:completion:` for Objective-C or
+ `signIn(withEmail:password:completion:)` for Swift instead.
@param email The user's email address.
@param password The user's password.
@@ -417,23 +418,62 @@ NS_SWIFT_NAME(Auth)
@remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
-
- @remarks This method will only exist until the next major Firebase release following 4.x.x.
- After the next major release the method `signInWithEmail:password:completion:` will support
- the `FIRAuthDataResultCallback`.
*/
- (void)signInAndRetrieveDataWithEmail:(NSString *)email
password:(NSString *)password
- completion:(nullable FIRAuthDataResultCallback)completion;
+ completion:(nullable FIRAuthDataResultCallback)completion
+ DEPRECATED_MSG_ATTRIBUTE(
+ "signInAndRetrieveDataWithEmail:password:completion: is "
+ "deprecated. Please use"
+ " signInWithEmail:password:completion: for Objective-C or"
+ " signIn(withEmail:password:completion:) for Swift instead.");
/** @fn signInWithCredential:completion:
- @brief Please use `signInAndRetrieveDataWithCredential:completion:` instead. This method
- doesn't return additional identity provider data.
+ @brief Please use `signInAndRetrieveDataWithCredential:completion:` for Objective-C or
+ `signInAndRetrieveData(with:completion:)` for swift instead
+
+ @param credential The credential supplied by the IdP.
+ @param completion Optionally; a block which is invoked when the sign in flow finishes, or is
+ canceled. Invoked asynchronously on the main thread in the future.
+
+ @remarks Possible error codes:
+
+ + `FIRAuthErrorCodeInvalidCredential` - Indicates the supplied credential is invalid.
+ This could happen if it has expired or it is malformed.
+ + `FIRAuthErrorCodeOperationNotAllowed` - Indicates that accounts
+ with the identity provider represented by the credential are not enabled.
+ Enable them in the Auth section of the Firebase console.
+ + `FIRAuthErrorCodeAccountExistsWithDifferentCredential` - Indicates the email asserted
+ by the credential (e.g. the email in a Facebook access token) is already in use by an
+ existing account, that cannot be authenticated with this sign-in method. Call
+ fetchProvidersForEmail for this user’s email and then prompt them to sign in with any of
+ the sign-in providers returned. This error will only be thrown if the "One account per
+ email address" setting is enabled in the Firebase console, under Auth settings.
+ + `FIRAuthErrorCodeUserDisabled` - Indicates the user's account is disabled.
+ + `FIRAuthErrorCodeWrongPassword` - Indicates the user attempted sign in with an
+ incorrect password, if credential is of the type EmailPasswordAuthCredential.
+ + `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
+ + `FIRAuthErrorCodeMissingVerificationID` - Indicates that the phone auth credential was
+ created with an empty verification ID.
+ + `FIRAuthErrorCodeMissingVerificationCode` - Indicates that the phone auth credential
+ was created with an empty verification code.
+ + `FIRAuthErrorCodeInvalidVerificationCode` - Indicates that the phone auth credential
+ was created with an invalid verification Code.
+ + `FIRAuthErrorCodeInvalidVerificationID` - Indicates that the phone auth credential was
+ created with an invalid verification ID.
+ + `FIRAuthErrorCodeSessionExpired` - Indicates that the SMS code has expired.
+
+
+
+ @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods
*/
- (void)signInWithCredential:(FIRAuthCredential *)credential
- completion:(nullable FIRAuthResultCallback)completion
- DEPRECATED_MSG_ATTRIBUTE("signInWithCredential: is deprecated. Please use "
- "signInAndRetrieveDataWithCredential:completion:` instead.");
+ completion:(nullable FIRAuthResultCallback)completion DEPRECATED_MSG_ATTRIBUTE(
+ "signInWithCredential:completion: is"
+ " deprecated. Please use"
+ " signInAndRetrieveDataWithCredential:completion: for"
+ " Objective-C or signInAndRetrieveData(with:completion:) for"
+ " Swift instead.");
/** @fn signInAndRetrieveDataWithCredential:completion:
@brief Asynchronously signs in to Firebase with the given 3rd-party credentials (e.g. a Facebook
@@ -473,7 +513,7 @@ NS_SWIFT_NAME(Auth)
- @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
+ @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods
*/
- (void)signInAndRetrieveDataWithCredential:(FIRAuthCredential *)credential
completion:(nullable FIRAuthDataResultCallback)completion;
@@ -493,10 +533,11 @@ NS_SWIFT_NAME(Auth)
@remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
*/
-- (void)signInAnonymouslyWithCompletion:(nullable FIRAuthResultCallback)completion;
+- (void)signInAnonymouslyWithCompletion:(nullable FIRAuthDataResultCallback)completion;
/** @fn signInAnonymouslyAndRetrieveDataWithCompletion:
- @brief Asynchronously creates and becomes an anonymous user.
+ @brief `Please use sign `signInAnonymouslyWithCompletion:` for Objective-C or
+ `signInAnonymously(Completion:)` for Swift instead.
@param completion Optionally; a block which is invoked when the sign in finishes, or is
canceled. Invoked asynchronously on the main thread in the future.
@@ -516,7 +557,10 @@ NS_SWIFT_NAME(Auth)
`FIRAuthDataResultCallback`.
*/
- (void)signInAnonymouslyAndRetrieveDataWithCompletion:
- (nullable FIRAuthDataResultCallback)completion;
+ (nullable FIRAuthDataResultCallback)completion
+ DEPRECATED_MSG_ATTRIBUTE("signInAnonymouslyAndRetrieveDataWithCompletion: is deprecated."
+ " Please use signInAnonymouslyWithCompletion: for Objective-C or"
+ " signInAnonymously(Completion:) for swift instead.");
/** @fn signInWithCustomToken:completion:
@brief Asynchronously signs in to Firebase with the given Auth token.
@@ -537,10 +581,11 @@ NS_SWIFT_NAME(Auth)
@remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
*/
- (void)signInWithCustomToken:(NSString *)token
- completion:(nullable FIRAuthResultCallback)completion;
+ completion:(nullable FIRAuthDataResultCallback)completion;
/** @fn signInAndRetrieveDataWithCustomToken:completion:
- @brief Asynchronously signs in to Firebase with the given Auth token.
+ @brief Please use `signInWithCustomToken:completion:` or `signIn(withCustomToken:completion:)`
+ for Swift instead.
@param token A self-signed custom auth token.
@param completion Optionally; a block which is invoked when the sign in finishes, or is
@@ -563,8 +608,12 @@ NS_SWIFT_NAME(Auth)
support the `FIRAuthDataResultCallback`.
*/
- (void)signInAndRetrieveDataWithCustomToken:(NSString *)token
- completion:(nullable FIRAuthDataResultCallback)completion;
-
+ completion:(nullable FIRAuthDataResultCallback)completion
+ DEPRECATED_MSG_ATTRIBUTE(
+ "signInAndRetrieveDataWithCustomToken:completion: is"
+ " deprecated. Please use signInWithCustomToken:completion:"
+ "for Objective-C or signIn(withCustomToken:completion:) for"
+ " Swift instead.");
/** @fn createUserWithEmail:password:completion:
@brief Creates and, on success, signs in a user with the given email address and password.