diff options
author | Morgan Chen <morganchen12@gmail.com> | 2018-06-20 10:14:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 10:14:10 -0700 |
commit | a4b7a244e7bc2778e7178f7855d58bb93f0deaf8 (patch) | |
tree | 50da184fddea28452b757d5cbb0b49ff1b4e0162 /Firebase/Auth/Source | |
parent | 468cb9151791a313d44e382976e6aa22fec45db4 (diff) | |
parent | 5fa4f5aac467db35654c0e3cf6920738cb4b8753 (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/Auth/Source')
-rw-r--r-- | Firebase/Auth/Source/FIRUser.m | 22 |
1 files changed, 17 insertions, 5 deletions
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); |