{"action":"created","comment":{"url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/comments/167308898","pull_request_review_id":95517624,"id":167308898,"diff_hunk":"@@ -108,35 +109,65 @@ - (void)signInWithDefaultValue:(NSString *)email andPassword:(NSString *)passwor\n   }\n \n   [self incrementActivity];\n-\n   FIRAuthCredential *credential =\n-      [FIREmailAuthProvider credentialWithEmail:email password:password];\n-  [self.auth signInAndRetrieveDataWithCredential:credential\n-                                      completion:^(FIRAuthDataResult *_Nullable authResult,\n-                                                   NSError *_Nullable error) {\n-    [self decrementActivity];\n-\n-    if (error) {\n-      switch (error.code) {\n-        case FIRAuthErrorCodeWrongPassword:\n-          [self showAlertWithMessage:FUILocalizedString(kStr_WrongPasswordError)];\n-          return;\n-        case FIRAuthErrorCodeUserNotFound:\n-          [self showAlertWithMessage:FUILocalizedString(kStr_UserNotFoundError)];\n-          return;\n-        case FIRAuthErrorCodeUserDisabled:\n-          [self showAlertWithMessage:FUILocalizedString(kStr_AccountDisabledError)];\n-          return;\n-        case FIRAuthErrorCodeTooManyRequests:\n-          [self showAlertWithMessage:FUILocalizedString(kStr_SignInTooManyTimesError)];\n+    [FIREmailAuthProvider credentialWithEmail:email password:password];\n+\n+    void (^completeSignInBlock)(FIRAuthDataResult *, NSError *) = ^(FIRAuthDataResult *authResult,\n+                                                                    NSError *error) {\n+      [self decrementActivity];\n+\n+      if (error) {\n+        switch (error.code) {\n+          case FIRAuthErrorCodeWrongPassword:\n+            [self showAlertWithMessage:FUILocalizedString(kStr_WrongPasswordError)];\n+            return;\n+          case FIRAuthErrorCodeUserNotFound:\n+            [self showAlertWithMessage:FUILocalizedString(kStr_UserNotFoundError)];\n+            return;\n+          case FIRAuthErrorCodeUserDisabled:\n+            [self showAlertWithMessage:FUILocalizedString(kStr_AccountDisabledError)];\n+            return;\n+          case FIRAuthErrorCodeTooManyRequests:\n+            [self showAlertWithMessage:FUILocalizedString(kStr_SignInTooManyTimesError)];\n+            return;\n+        }\n+      }\n+      [self.navigationController dismissViewControllerAnimated:YES completion:^{\n+        [self.authUI invokeResultCallbackWithAuthDataResult:authResult error:error];\n+      }];\n+    };\n+\n+  // Check for the presence of an anonymous user and whether automatic upgrade is enabled.\n+  if (self.auth.currentUser.isAnonymous &&\n+    [FUIAuth defaultAuthUI].shouldAutoUpgradeAnonymousUsers) {\n+\n+    [self.auth.currentUser\n+        linkAndRetrieveDataWithCredential:credential\n+                               completion:^(FIRAuthDataResult *_Nullable authResult,\n+                                            NSError *_Nullable error) {\n+      if (error) {\n+        if (error.code == FIRAuthErrorCodeEmailAlreadyInUse) {\n+          NSDictionary *userInfo = @{ FUIAuthCredentialKey : credential };\n+          NSError *mergeError = [NSError errorWithDomain:FUIAuthErrorDomain\n+                                                    code:FUIAuthErrorCodeMergeConflict\n+                                                userInfo:userInfo];\n+          [self.navigationController dismissViewControllerAnimated:YES completion:^{\n+            [self.authUI invokeResultCallbackWithAuthDataResult:authResult error:mergeError];\n+          }];\n           return;\n+        }\n+        completeSignInBlock(nil, error);\n+        return;\n       }\n-    }\n-    \n-    [self.navigationController dismissViewControllerAnimated:YES completion:^{\n-      [self.authUI invokeResultCallbackWithAuthDataResult:authResult error:error];\n+      completeSignInBlock(authResult, nil);\n+    }];\n+  } else {\n+    [self.auth signInAndRetrieveDataWithCredential:credential\n+                                        completion:^(FIRAuthDataResult *_Nullable authResult,\n+                                                     NSError *_Nullable error) {\n+      completeSignInBlock(authResult, error);\n     }];","path":"FirebaseAuthUI/FUIPasswordSignInViewController.m","position":null,"original_position":93,"commit_id":"241119b16f5ad8c83e89bf8605155045e0ab8431","original_commit_id":"d6e64daa7e8f8ce1695940506a59acc4c5362864","user":{"login":"protocol86","id":18198771,"avatar_url":"https://avatars0.githubusercontent.com/u/18198771?v=4","gravatar_id":"","url":"https://api.github.com/users/protocol86","html_url":"https://github.com/protocol86","followers_url":"https://api.github.com/users/protocol86/followers","following_url":"https://api.github.com/users/protocol86/following{/other_user}","gists_url":"https://api.github.com/users/protocol86/gists{/gist_id}","starred_url":"https://api.github.com/users/protocol86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/protocol86/subscriptions","organizations_url":"https://api.github.com/users/protocol86/orgs","repos_url":"https://api.github.com/users/protocol86/repos","events_url":"https://api.github.com/users/protocol86/events{/privacy}","received_events_url":"https://api.github.com/users/protocol86/received_events","type":"User","site_admin":false},"body":"Done :)","created_at":"2018-02-09T18:30:36Z","updated_at":"2018-02-09T18:30:36Z","html_url":"https://github.com/firebase/FirebaseUI-iOS/pull/405#discussion_r167308898","pull_request_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/comments/167308898"},"html":{"href":"https://github.com/firebase/FirebaseUI-iOS/pull/405#discussion_r167308898"},"pull_request":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405"}},"in_reply_to_id":167019929},"pull_request":{"url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405","id":167869126,"html_url":"https://github.com/firebase/FirebaseUI-iOS/pull/405","diff_url":"https://github.com/firebase/FirebaseUI-iOS/pull/405.diff","patch_url":"https://github.com/firebase/FirebaseUI-iOS/pull/405.patch","issue_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/405","number":405,"state":"open","locked":false,"title":"anonymous upgrade for email password accounts","user":{"login":"protocol86","id":18198771,"avatar_url":"https://avatars0.githubusercontent.com/u/18198771?v=4","gravatar_id":"","url":"https://api.github.com/users/protocol86","html_url":"https://github.com/protocol86","followers_url":"https://api.github.com/users/protocol86/followers","following_url":"https://api.github.com/users/protocol86/following{/other_user}","gists_url":"https://api.github.com/users/protocol86/gists{/gist_id}","starred_url":"https://api.github.com/users/protocol86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/protocol86/subscriptions","organizations_url":"https://api.github.com/users/protocol86/orgs","repos_url":"https://api.github.com/users/protocol86/repos","events_url":"https://api.github.com/users/protocol86/events{/privacy}","received_events_url":"https://api.github.com/users/protocol86/received_events","type":"User","site_admin":false},"body":"Adds anonymous upgrade support for email/password credentials.","created_at":"2018-02-08T03:30:49Z","updated_at":"2018-02-09T18:30:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02ef27253b3142ccc495c575364d891869112164","assignee":null,"assignees":[],"requested_reviewers":[{"login":"yramanchuk","id":8353656,"avatar_url":"https://avatars0.githubusercontent.com/u/8353656?v=4","gravatar_id":"","url":"https://api.github.com/users/yramanchuk","html_url":"https://github.com/yramanchuk","followers_url":"https://api.github.com/users/yramanchuk/followers","following_url":"https://api.github.com/users/yramanchuk/following{/other_user}","gists_url":"https://api.github.com/users/yramanchuk/gists{/gist_id}","starred_url":"https://api.github.com/users/yramanchuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yramanchuk/subscriptions","organizations_url":"https://api.github.com/users/yramanchuk/orgs","repos_url":"https://api.github.com/users/yramanchuk/repos","events_url":"https://api.github.com/users/yramanchuk/events{/privacy}","received_events_url":"https://api.github.com/users/yramanchuk/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405/commits","review_comments_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405/comments","review_comment_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/405/comments","statuses_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/statuses/241119b16f5ad8c83e89bf8605155045e0ab8431","head":{"label":"firebase:anonymous_user_upgrade_email_password","ref":"anonymous_user_upgrade_email_password","sha":"241119b16f5ad8c83e89bf8605155045e0ab8431","user":{"login":"firebase","id":1335026,"avatar_url":"https://avatars2.githubusercontent.com/u/1335026?v=4","gravatar_id":"","url":"https://api.github.com/users/firebase","html_url":"https://github.com/firebase","followers_url":"https://api.github.com/users/firebase/followers","following_url":"https://api.github.com/users/firebase/following{/other_user}","gists_url":"https://api.github.com/users/firebase/gists{/gist_id}","starred_url":"https://api.github.com/users/firebase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebase/subscriptions","organizations_url":"https://api.github.com/users/firebase/orgs","repos_url":"https://api.github.com/users/firebase/repos","events_url":"https://api.github.com/users/firebase/events{/privacy}","received_events_url":"https://api.github.com/users/firebase/received_events","type":"Organization","site_admin":false},"repo":{"id":38835282,"name":"FirebaseUI-iOS","full_name":"firebase/FirebaseUI-iOS","owner":{"login":"firebase","id":1335026,"avatar_url":"https://avatars2.githubusercontent.com/u/1335026?v=4","gravatar_id":"","url":"https://api.github.com/users/firebase","html_url":"https://github.com/firebase","followers_url":"https://api.github.com/users/firebase/followers","following_url":"https://api.github.com/users/firebase/following{/other_user}","gists_url":"https://api.github.com/users/firebase/gists{/gist_id}","starred_url":"https://api.github.com/users/firebase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebase/subscriptions","organizations_url":"https://api.github.com/users/firebase/orgs","repos_url":"https://api.github.com/users/firebase/repos","events_url":"https://api.github.com/users/firebase/events{/privacy}","received_events_url":"https://api.github.com/users/firebase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firebase/FirebaseUI-iOS","description":"iOS UI bindings for Firebase.","fork":false,"url":"https://api.github.com/repos/firebase/FirebaseUI-iOS","forks_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/forks","keys_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/teams","hooks_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/hooks","issue_events_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/events{/number}","events_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/events","assignees_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/assignees{/user}","branches_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/branches{/branch}","tags_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/tags","blobs_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/refs{/sha}","trees_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/statuses/{sha}","languages_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/languages","stargazers_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/stargazers","contributors_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/contributors","subscribers_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/subscribers","subscription_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/subscription","commits_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/commits{/sha}","git_commits_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/commits{/sha}","comments_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/comments{/number}","issue_comment_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/comments{/number}","contents_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/contents/{+path}","compare_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/merges","archive_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/downloads","issues_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues{/number}","pulls_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls{/number}","milestones_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/milestones{/number}","notifications_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/labels{/name}","releases_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/releases{/id}","deployments_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/deployments","created_at":"2015-07-09T17:32:23Z","updated_at":"2018-02-07T05:22:00Z","pushed_at":"2018-02-09T18:30:26Z","git_url":"git://github.com/firebase/FirebaseUI-iOS.git","ssh_url":"git@github.com:firebase/FirebaseUI-iOS.git","clone_url":"https://github.com/firebase/FirebaseUI-iOS.git","svn_url":"https://github.com/firebase/FirebaseUI-iOS","homepage":"","size":363222,"stargazers_count":821,"watchers_count":821,"language":"Objective-C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":258,"mirror_url":null,"archived":false,"open_issues_count":29,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":258,"open_issues":29,"watchers":821,"default_branch":"master"}},"base":{"label":"firebase:anonymous_updgrade_master","ref":"anonymous_updgrade_master","sha":"3fa49f5f9e0a4e455832b40d967fcd3a12a19a76","user":{"login":"firebase","id":1335026,"avatar_url":"https://avatars2.githubusercontent.com/u/1335026?v=4","gravatar_id":"","url":"https://api.github.com/users/firebase","html_url":"https://github.com/firebase","followers_url":"https://api.github.com/users/firebase/followers","following_url":"https://api.github.com/users/firebase/following{/other_user}","gists_url":"https://api.github.com/users/firebase/gists{/gist_id}","starred_url":"https://api.github.com/users/firebase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebase/subscriptions","organizations_url":"https://api.github.com/users/firebase/orgs","repos_url":"https://api.github.com/users/firebase/repos","events_url":"https://api.github.com/users/firebase/events{/privacy}","received_events_url":"https://api.github.com/users/firebase/received_events","type":"Organization","site_admin":false},"repo":{"id":38835282,"name":"FirebaseUI-iOS","full_name":"firebase/FirebaseUI-iOS","owner":{"login":"firebase","id":1335026,"avatar_url":"https://avatars2.githubusercontent.com/u/1335026?v=4","gravatar_id":"","url":"https://api.github.com/users/firebase","html_url":"https://github.com/firebase","followers_url":"https://api.github.com/users/firebase/followers","following_url":"https://api.github.com/users/firebase/following{/other_user}","gists_url":"https://api.github.com/users/firebase/gists{/gist_id}","starred_url":"https://api.github.com/users/firebase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebase/subscriptions","organizations_url":"https://api.github.com/users/firebase/orgs","repos_url":"https://api.github.com/users/firebase/repos","events_url":"https://api.github.com/users/firebase/events{/privacy}","received_events_url":"https://api.github.com/users/firebase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firebase/FirebaseUI-iOS","description":"iOS UI bindings for Firebase.","fork":false,"url":"https://api.github.com/repos/firebase/FirebaseUI-iOS","forks_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/forks","keys_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/teams","hooks_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/hooks","issue_events_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/events{/number}","events_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/events","assignees_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/assignees{/user}","branches_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/branches{/branch}","tags_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/tags","blobs_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/refs{/sha}","trees_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/statuses/{sha}","languages_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/languages","stargazers_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/stargazers","contributors_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/contributors","subscribers_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/subscribers","subscription_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/subscription","commits_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/commits{/sha}","git_commits_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/git/commits{/sha}","comments_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/comments{/number}","issue_comment_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/comments{/number}","contents_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/contents/{+path}","compare_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/merges","archive_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/downloads","issues_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues{/number}","pulls_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls{/number}","milestones_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/milestones{/number}","notifications_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/labels{/name}","releases_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/releases{/id}","deployments_url":"https://api.github.com/repos/firebase/FirebaseUI-iOS/deployments","created_at":"2015-07-09T17:32:23Z","updated_at":"2018-02-07T05:22:00Z","pushed_at":"2018-02-09T18:30:26Z","git_url":"git://github.com/firebase/FirebaseUI-iOS.git","ssh_url":"git@github.com:firebase/FirebaseUI-iOS.git","clone_url":"https://github.com/firebase/FirebaseUI-iOS.git","svn_url":"https://github.com/firebase/FirebaseUI-iOS","homepage":"","size":363222,"stargazers_count":821,"watchers_count":821,"language":"Objective-C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":258,"mirror_url":null,"archived":false,"open_issues_count":29,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":258,"open_issues":29,"watchers":821,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405"},"html":{"href":"https://github.com/firebase/FirebaseUI-iOS/pull/405"},"issue":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/405"},"comments":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/issues/405/comments"},"review_comments":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405/comments"},"review_comment":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/pulls/405/commits"},"statuses":{"href":"https://api.github.com/repos/firebase/FirebaseUI-iOS/statuses/241119b16f5ad8c83e89bf8605155045e0ab8431"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"protocol86"}}