diff options
Diffstat (limited to 'Firebase/Auth/Source/FIRUser.m')
-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); |