aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Morgan Chen <morganchen12@gmail.com>2018-06-20 10:14:10 -0700
committerGravatar GitHub <noreply@github.com>2018-06-20 10:14:10 -0700
commita4b7a244e7bc2778e7178f7855d58bb93f0deaf8 (patch)
tree50da184fddea28452b757d5cbb0b49ff1b4e0162 /Firebase
parent468cb9151791a313d44e382976e6aa22fec45db4 (diff)
parent5fa4f5aac467db35654c0e3cf6920738cb4b8753 (diff)
Merge pull request #1383 from morganchen12/auth2
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);