diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2018-02-26 09:48:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-26 09:48:09 -0800 |
commit | d4ec10577a40e8a913070cf40a29636c41aafbd2 (patch) | |
tree | 74267fbcdb2d4b7707a9989d31a47e9f309a5f28 /Firebase/Auth/Source/FIRUser.m | |
parent | 13e366738463739f0c21d4cedab4bafbfdb57c6f (diff) |
Fixes clang warnings for Auth (#848)
* Fixes clang warnings for Auth
* Addresses comments
Diffstat (limited to 'Firebase/Auth/Source/FIRUser.m')
-rw-r--r-- | Firebase/Auth/Source/FIRUser.m | 101 |
1 files changed, 51 insertions, 50 deletions
diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m index 6af263d..a77db75 100644 --- a/Firebase/Auth/Source/FIRUser.m +++ b/Firebase/Auth/Source/FIRUser.m @@ -383,7 +383,7 @@ static void callInMainThreadWithAuthDataResultAndError( } FIRGetAccountInfoRequest *getAccountInfoRequest = [[FIRGetAccountInfoRequest alloc] initWithAccessToken:accessToken - requestConfiguration:_auth.requestConfiguration]; + requestConfiguration:self->_auth.requestConfiguration]; [FIRAuthBackend getAccountInfo:getAccountInfoRequest callback:^(FIRGetAccountInfoResponse *_Nullable response, NSError *_Nullable error) { @@ -451,7 +451,7 @@ static void callInMainThreadWithAuthDataResultAndError( callback(error); return; } - FIRAuthRequestConfiguration *configuration = _auth.requestConfiguration; + FIRAuthRequestConfiguration *configuration = self->_auth.requestConfiguration; // Mutate setAccountInfoRequest in block: FIRSetAccountInfoRequest *setAccountInfoRequest = [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:configuration]; @@ -513,7 +513,7 @@ static void callInMainThreadWithAuthDataResultAndError( callback(error); return; } - _tokenService = tokenService; + self->_tokenService = tokenService; if (![self updateKeychain:&error]) { callback(error); return; @@ -558,11 +558,11 @@ static void callInMainThreadWithAuthDataResultAndError( return; } if (email) { - _email = email; + self->_email = email; } - if (_email && password) { - _anonymous = NO; - _hasEmailPasswordCredential = YES; + if (self->_email && password) { + self->_anonymous = NO; + self->_hasEmailPasswordCredential = YES; if (!hadEmailPasswordCredential) { // The list of providers need to be updated for the newly added email-password provider. [self internalGetTokenWithCallback:^(NSString *_Nullable accessToken, @@ -571,7 +571,7 @@ static void callInMainThreadWithAuthDataResultAndError( callback(error); return; } - FIRAuthRequestConfiguration *requestConfiguration = _auth.requestConfiguration; + FIRAuthRequestConfiguration *requestConfiguration = self->_auth.requestConfiguration; FIRGetAccountInfoRequest *getAccountInfoRequest = [[FIRGetAccountInfoRequest alloc] initWithAccessToken:accessToken requestConfiguration:requestConfiguration]; @@ -646,7 +646,7 @@ static void callInMainThreadWithAuthDataResultAndError( initWithVerificationID:phoneAuthCredential.verificationID verificationCode:phoneAuthCredential.verificationCode operation:operation - requestConfiguration:_auth.requestConfiguration]; + requestConfiguration:self->_auth.requestConfiguration]; request.accessToken = accessToken; [FIRAuthBackend verifyPhoneNumber:request callback:^(FIRVerifyPhoneNumberResponse *_Nullable response, @@ -664,7 +664,7 @@ static void callInMainThreadWithAuthDataResultAndError( completion(error); return; } - _anonymous = NO; + self->_anonymous = NO; if (![self updateKeychain:&error]) { completion(error); return; @@ -737,10 +737,11 @@ static void callInMainThreadWithAuthDataResultAndError( reauthenticateAndRetrieveDataWithCredential:(FIRAuthCredential *) credential completion:(nullable FIRAuthDataResultCallback) completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^{ - [_auth internalSignInAndRetrieveDataWithCredential:credential - isReauthentication:YES - callback:^(FIRAuthDataResult *_Nullable authResult, - NSError *_Nullable error) { + [self->_auth internalSignInAndRetrieveDataWithCredential:credential + isReauthentication:YES + callback:^(FIRAuthDataResult *_Nullable + authResult, + NSError *_Nullable error) { if (error) { // If "user not found" error returned by backend, translate to user mismatch error which is // more accurate. @@ -750,7 +751,7 @@ static void callInMainThreadWithAuthDataResultAndError( callInMainThreadWithAuthDataResultAndError(completion, authResult, error); return; } - if (![authResult.user.uid isEqual:[_auth getUID]]) { + if (![authResult.user.uid isEqual:[self->_auth getUID]]) { callInMainThreadWithAuthDataResultAndError(completion, authResult, [FIRAuthErrorUtils userMismatchError]); return; @@ -766,7 +767,7 @@ static void callInMainThreadWithAuthDataResultAndError( - (nullable NSString *)refreshToken { __block NSString *result; dispatch_sync(FIRAuthGlobalWorkQueue(), ^{ - result = _tokenService.refreshToken; + result = self->_tokenService.refreshToken; }); return result; } @@ -842,7 +843,7 @@ static void callInMainThreadWithAuthDataResultAndError( - (void)linkAndRetrieveDataWithCredential:(FIRAuthCredential *)credential completion:(nullable FIRAuthDataResultCallback)completion { dispatch_async(FIRAuthGlobalWorkQueue(), ^{ - if (_providerData[credential.provider]) { + if (self->_providerData[credential.provider]) { callInMainThreadWithAuthDataResultAndError(completion, nil, [FIRAuthErrorUtils providerAlreadyLinkedError]); @@ -851,7 +852,7 @@ static void callInMainThreadWithAuthDataResultAndError( FIRAuthDataResult *result = [[FIRAuthDataResult alloc] initWithUser:self additionalUserInfo:nil]; if ([credential isKindOfClass:[FIREmailPasswordAuthCredential class]]) { - if (_hasEmailPasswordCredential) { + if (self->_hasEmailPasswordCredential) { callInMainThreadWithAuthDataResultAndError(completion, nil, [FIRAuthErrorUtils providerAlreadyLinkedError]); @@ -887,7 +888,7 @@ static void callInMainThreadWithAuthDataResultAndError( } #endif - [_taskQueue enqueueTask:^(FIRAuthSerialTaskCompletionBlock _Nonnull complete) { + [self->_taskQueue enqueueTask:^(FIRAuthSerialTaskCompletionBlock _Nonnull complete) { CallbackWithAuthDataResultAndError completeWithError = ^(FIRAuthDataResult *result, NSError *error) { complete(); @@ -899,7 +900,7 @@ static void callInMainThreadWithAuthDataResultAndError( completeWithError(nil, error); return; } - FIRAuthRequestConfiguration *requestConfiguration = _auth.requestConfiguration; + FIRAuthRequestConfiguration *requestConfiguration = self->_auth.requestConfiguration; FIRVerifyAssertionRequest *request = [[FIRVerifyAssertionRequest alloc] initWithProviderID:credential.provider requestConfiguration:requestConfiguration]; @@ -917,7 +918,7 @@ static void callInMainThreadWithAuthDataResultAndError( FIRAuthDataResult *result = [[FIRAuthDataResult alloc] initWithUser:self additionalUserInfo:additionalUserInfo]; // Update the new token and refresh user info again. - _tokenService = [[FIRSecureTokenService alloc] + self->_tokenService = [[FIRSecureTokenService alloc] initWithRequestConfiguration:requestConfiguration accessToken:response.IDToken accessTokenExpirationDate:response.approximateExpirationDate @@ -939,7 +940,7 @@ static void callInMainThreadWithAuthDataResultAndError( completeWithError(nil, error); return; } - _anonymous = NO; + self->_anonymous = NO; [self updateWithGetAccountInfoResponse:response]; if (![self updateKeychain:&error]) { completeWithError(nil, error); @@ -967,19 +968,19 @@ static void callInMainThreadWithAuthDataResultAndError( completeAndCallbackWithError(error); return; } - FIRAuthRequestConfiguration *requestConfiguration = _auth.requestConfiguration; + FIRAuthRequestConfiguration *requestConfiguration = self->_auth.requestConfiguration; FIRSetAccountInfoRequest *setAccountInfoRequest = [[FIRSetAccountInfoRequest alloc] initWithRequestConfiguration:requestConfiguration]; setAccountInfoRequest.accessToken = accessToken; BOOL isEmailPasswordProvider = [provider isEqualToString:FIREmailAuthProviderID]; if (isEmailPasswordProvider) { - if (!_hasEmailPasswordCredential) { + if (!self->_hasEmailPasswordCredential) { completeAndCallbackWithError([FIRAuthErrorUtils noSuchProviderError]); return; } setAccountInfoRequest.deleteAttributes = @[ FIRSetAccountInfoUserAttributePassword ]; } else { - if (!_providerData[provider]) { + if (!self->_providerData[provider]) { completeAndCallbackWithError([FIRAuthErrorUtils noSuchProviderError]); return; } @@ -994,19 +995,19 @@ static void callInMainThreadWithAuthDataResultAndError( return; } if (isEmailPasswordProvider) { - _hasEmailPasswordCredential = NO; + self->_hasEmailPasswordCredential = NO; } else { // We can't just use the provider info objects in FIRSetAcccountInfoResponse because they // don't have localID and email fields. Remove the specific provider manually. - NSMutableDictionary *mutableProviderData = [_providerData mutableCopy]; + NSMutableDictionary *mutableProviderData = [self->_providerData mutableCopy]; [mutableProviderData removeObjectForKey:provider]; - _providerData = [mutableProviderData copy]; + self->_providerData = [mutableProviderData copy]; #if TARGET_OS_IOS // After successfully unlinking a phone auth provider, remove the phone number from the // cached user info. if ([provider isEqualToString:FIRPhoneAuthProviderID]) { - _phoneNumber = nil; + self->_phoneNumber = nil; } #endif } @@ -1060,7 +1061,7 @@ static void callInMainThreadWithAuthDataResultAndError( callInMainThreadWithError(completion, error); return; } - FIRAuthRequestConfiguration *configuration = _auth.requestConfiguration; + FIRAuthRequestConfiguration *configuration = self->_auth.requestConfiguration; FIRGetOOBConfirmationCodeRequest *request = [FIRGetOOBConfirmationCodeRequest verifyEmailRequestWithAccessToken:accessToken actionCodeSettings:actionCodeSettings @@ -1085,15 +1086,15 @@ static void callInMainThreadWithAuthDataResultAndError( return; } FIRDeleteAccountRequest *deleteUserRequest = - [[FIRDeleteAccountRequest alloc] initWitLocalID:_userID + [[FIRDeleteAccountRequest alloc] initWitLocalID:self->_userID accessToken:accessToken - requestConfiguration:_auth.requestConfiguration]; + requestConfiguration:self->_auth.requestConfiguration]; [FIRAuthBackend deleteAccount:deleteUserRequest callback:^(NSError *_Nullable error) { if (error) { callInMainThreadWithError(completion, error); return; } - if (![_auth signOutByForceWithUserID:_userID error:&error]) { + if (![self->_auth signOutByForceWithUserID:self->_userID error:&error]) { callInMainThreadWithError(completion, error); return; } @@ -1167,14 +1168,14 @@ static void callInMainThreadWithAuthDataResultAndError( - (void)setDisplayName:(nullable NSString *)displayName { dispatch_sync(FIRAuthGlobalWorkQueue(), ^{ - if (_consumed) { + if (self->_consumed) { [NSException raise:NSInternalInconsistencyException format:@"%@", @"Invalid call to setDisplayName: after commitChangesWithCallback:."]; return; } - _displayNameSet = YES; - _displayName = [displayName copy]; + self->_displayNameSet = YES; + self->_displayName = [displayName copy]; }); } @@ -1184,14 +1185,14 @@ static void callInMainThreadWithAuthDataResultAndError( - (void)setPhotoURL:(nullable NSURL *)photoURL { dispatch_sync(FIRAuthGlobalWorkQueue(), ^{ - if (_consumed) { + if (self->_consumed) { [NSException raise:NSInternalInconsistencyException format:@"%@", @"Invalid call to setPhotoURL: after commitChangesWithCallback:."]; return; } - _photoURLSet = YES; - _photoURL = [photoURL copy]; + self->_photoURLSet = YES; + self->_photoURL = [photoURL copy]; }); } @@ -1204,24 +1205,24 @@ static void callInMainThreadWithAuthDataResultAndError( - (void)commitChangesWithCompletion:(nullable FIRUserProfileChangeCallback)completion { dispatch_sync(FIRAuthGlobalWorkQueue(), ^{ - if (_consumed) { + if (self->_consumed) { [NSException raise:NSInternalInconsistencyException format:@"%@", @"commitChangesWithCallback: should only be called once."]; return; } - _consumed = YES; + self->_consumed = YES; // Return fast if there is nothing to update: if (![self hasUpdates]) { callInMainThreadWithError(completion, nil); return; } - NSString *displayName = [_displayName copy]; - BOOL displayNameWasSet = _displayNameSet; - NSURL *photoURL = [_photoURL copy]; - BOOL photoURLWasSet = _photoURLSet; - [_user executeUserUpdateWithChanges:^(FIRGetAccountInfoResponseUser *user, - FIRSetAccountInfoRequest *request) { + NSString *displayName = [self->_displayName copy]; + BOOL displayNameWasSet = self->_displayNameSet; + NSURL *photoURL = [self->_photoURL copy]; + BOOL photoURLWasSet = self->_photoURLSet; + [self->_user executeUserUpdateWithChanges:^(FIRGetAccountInfoResponseUser *user, + FIRSetAccountInfoRequest *request) { if (photoURLWasSet) { request.photoURL = photoURL; } @@ -1235,12 +1236,12 @@ static void callInMainThreadWithAuthDataResultAndError( return; } if (displayNameWasSet) { - [_user setDisplayName:displayName]; + [self->_user setDisplayName:displayName]; } if (photoURLWasSet) { - [_user setPhotoURL:photoURL]; + [self->_user setPhotoURL:photoURL]; } - if (![_user updateKeychain:&error]) { + if (![self->_user updateKeychain:&error]) { callInMainThreadWithError(completion, error); return; } |