From 2b946459b590259f9006783e45051bdfaee89afb Mon Sep 17 00:00:00 2001
From: vrana
Date: Mon, 25 Jun 2012 17:45:22 -0700
Subject: [PATCH] Inform user about associated accounts in failed login
Summary:
Sometimes people create their account in Phabricator using some OAuth provider, forget about it and then tries to login with another provider.
Provide this information to them.
Test Plan: Tried to link an account linked to already existing user.
Reviewers: epriestley
Reviewed By: epriestley
CC: robarnold, aran, Korvin
Differential Revision: https://secure.phabricator.com/D2857
---
.../PhabricatorOAuthLoginController.php | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/applications/auth/controller/PhabricatorOAuthLoginController.php b/src/applications/auth/controller/PhabricatorOAuthLoginController.php
index 8591c63c1d..62da43d8c7 100644
--- a/src/applications/auth/controller/PhabricatorOAuthLoginController.php
+++ b/src/applications/auth/controller/PhabricatorOAuthLoginController.php
@@ -192,6 +192,24 @@ final class PhabricatorOAuthLoginController
'accounts, log in to your Phabricator account and then go to '.
'Settings.
',
$provider_name));
+
+ $user = id(new PhabricatorUser())
+ ->loadOneWhere('phid = %s', $known_email->getUserPHID());
+ $oauth_infos = id(new PhabricatorUserOAuthInfo())
+ ->loadAllWhere('userID = %d', $user->getID());
+ if ($oauth_infos) {
+ $providers = array();
+ foreach ($oauth_infos as $info) {
+ $provider = $info->getOAuthProvider();
+ $providers[] = PhabricatorOAuthProvider::newProvider($provider)
+ ->getProviderName();
+ }
+ $dialog->appendChild(
+ hsprintf(
+ 'The account is associated with: %s.
',
+ implode(', ', $providers)));
+ }
+
$dialog->addCancelButton('/login/');
return id(new AphrontDialogResponse())->setDialog($dialog);