Explorar o código

Fix callback for nested `signIn` or `addScopes` (#29)

* fix calling callback on addScopes

* fixes due review
Anton %!s(int64=4) %!d(string=hai) anos
pai
achega
e6d17e907b
Modificáronse 1 ficheiros con 5 adicións e 4 borrados
  1. 5 4
      GoogleSignIn/Sources/GIDSignIn.m

+ 5 - 4
GoogleSignIn/Sources/GIDSignIn.m

@@ -390,9 +390,9 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
         [self authenticateWithOptions:options];
       } else {
         if (options.callback) {
+          self->_currentOptions = nil;
           dispatch_async(dispatch_get_main_queue(), ^{
             options.callback(self->_currentUser, nil);
-            self->_currentOptions = nil;
           });
         }
       }
@@ -522,9 +522,9 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
                                          code:kGIDSignInErrorCodeHasNoAuthInKeychain
                                      userInfo:nil];
     if (options.callback) {
+      self->_currentOptions = nil;
       dispatch_async(dispatch_get_main_queue(), ^{
         options.callback(nil, error);
-        self->_currentOptions = nil;
       });
     }
     return;
@@ -690,9 +690,10 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   [authFlow addCallback:^() {
     GIDAuthFlow *handlerAuthFlow = weakAuthFlow;
     if (self->_currentOptions.callback) {
+      GIDSignInCallback callback = self->_currentOptions.callback;
+      self->_currentOptions = nil;
       dispatch_async(dispatch_get_main_queue(), ^{
-        self->_currentOptions.callback(self->_currentUser, handlerAuthFlow.error);
-        self->_currentOptions = nil;
+        callback(self->_currentUser, handlerAuthFlow.error);
       });
     }
   }];