aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Morgan Chen <morganchen12@gmail.com>2018-06-05 17:11:31 -0700
committerGravatar Morgan Chen <morganchen12@gmail.com>2018-06-19 16:55:40 -0700
commit5fa4f5aac467db35654c0e3cf6920738cb4b8753 (patch)
tree8f001b4cfc17871ea260094594676c348922c5d2 /Firebase
parent8b703e3b04f9b3784a93fe3fa579a1d8f07e981e (diff)
Promote users to non-anonymous status even when linking account w/o pw
Diffstat (limited to 'Firebase')
-rw-r--r--Firebase/Auth/CHANGELOG.md4
-rw-r--r--Firebase/Auth/Source/FIRUser.m22
2 files changed, 21 insertions, 5 deletions
diff --git a/Firebase/Auth/CHANGELOG.md b/Firebase/Auth/CHANGELOG.md
index 292f8bd..2669fc0 100644
--- a/Firebase/Auth/CHANGELOG.md
+++ b/Firebase/Auth/CHANGELOG.md
@@ -1,3 +1,7 @@
+# v5.0.2
+- Fix an issue where anonymous accounts weren't correctly promoted to
+ non-anonymous when linked with passwordless email auth accounts.
+
# v5.0.1
- Restore 4.x level of support for extensions (#1357).
diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m
index 04aa861..3f5bf35 100644
--- a/Firebase/Auth/Source/FIRUser.m
+++ b/Firebase/Auth/Source/FIRUser.m
@@ -541,7 +541,7 @@ static void callInMainThreadWithAuthDataResultAndError(
- (void)updateEmail:(nullable NSString *)email
password:(nullable NSString *)password
callback:(nonnull FIRUserProfileChangeCallback)callback {
- if (password && ![password length]){
+ if (password && ![password length]) {
callback([FIRAuthErrorUtils weakPasswordErrorWithServerResponseReason:kMissingPasswordReason]);
return;
}
@@ -561,11 +561,9 @@ static void callInMainThreadWithAuthDataResultAndError(
return;
}
if (email) {
- self->_email = email;
+ self->_email = [email copy];
}
- if (self->_email && password) {
- self->_anonymous = NO;
- self->_hasEmailPasswordCredential = YES;
+ if (self->_email) {
if (!hadEmailPasswordCredential) {
// The list of providers need to be updated for the newly added email-password provider.
[self internalGetTokenWithCallback:^(NSString *_Nullable accessToken,
@@ -586,6 +584,20 @@ static void callInMainThreadWithAuthDataResultAndError(
callback(error);
return;
}
+ for (FIRGetAccountInfoResponseUser *userAccountInfo in response.users) {
+ // Set the account to non-anonymous if there are any providers, even if
+ // they're not email/password ones.
+ if (userAccountInfo.providerUserInfo.count > 0) {
+ self->_anonymous = NO;
+ }
+ for (FIRGetAccountInfoResponseProviderUserInfo *providerUserInfo in
+ userAccountInfo.providerUserInfo) {
+ if ([providerUserInfo.providerID isEqualToString:FIREmailAuthProviderID]) {
+ self->_hasEmailPasswordCredential = YES;
+ break;
+ }
+ }
+ }
[self updateWithGetAccountInfoResponse:response];
if (![self updateKeychain:&error]) {
callback(error);