diff --git a/conf/default.conf.php b/conf/default.conf.php index a5bb05d2fa..cf02b03b6a 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -42,5 +42,7 @@ return array( 'recaptcha.private-key' => null, + 'user.default-profile-image-phid' => 'PHID-FILE-f57aaefce707fc4060ef', + ); diff --git a/src/applications/auth/controller/facebookauth/PhabricatorFacebookAuthController.php b/src/applications/auth/controller/facebookauth/PhabricatorFacebookAuthController.php index 7f86928722..818e291d21 100644 --- a/src/applications/auth/controller/facebookauth/PhabricatorFacebookAuthController.php +++ b/src/applications/auth/controller/facebookauth/PhabricatorFacebookAuthController.php @@ -131,6 +131,24 @@ class PhabricatorFacebookAuthController extends PhabricatorAuthController { return id(new AphrontRedirectResponse()) ->setURI('/'); } + + $known_email = id(new PhabricatorUser()) + ->loadOneWhere('email = %s', $user_data['email']); + if ($known_email) { + if ($known_email->getFacebookUID()) { + throw new Exception( + "The email associated with the Facebook account you just logged in ". + "with is already associated with another Phabricator account which ". + "is, in turn, associated with a Facebook account different from ". + "the one you just logged in with."); + } + $known_email->setFacebookUID($user_id); + $session_key = $known_email->establishSession('web'); + $request->setCookie('phusr', $known_email->getUsername()); + $request->setCookie('phsid', $session_key); + return id(new AphrontRedirectResponse()) + ->setURI('/'); + } $current_user = $this->getRequest()->getUser(); if ($current_user->getPHID()) { diff --git a/src/applications/auth/controller/login/PhabricatorLoginController.php b/src/applications/auth/controller/login/PhabricatorLoginController.php index dc871ccb44..774a26d7e9 100644 --- a/src/applications/auth/controller/login/PhabricatorLoginController.php +++ b/src/applications/auth/controller/login/PhabricatorLoginController.php @@ -85,6 +85,7 @@ class PhabricatorLoginController extends PhabricatorAuthController { $panel = new AphrontPanelView(); $panel->setHeader('Phabricator Login'); $panel->setWidth(AphrontPanelView::WIDTH_FORM); +// $panel->setCreateButton('Register New Account', '/login/register/'); $panel->appendChild($form); $fbauth_enabled = PhabricatorEnv::getEnvConfig('facebook.auth-enabled'); @@ -117,7 +118,7 @@ class PhabricatorLoginController extends PhabricatorAuthController { id(new AphrontFormSubmitControl()) ->setValue("Login with Facebook \xC2\xBB")); - $panel->appendChild('

Login with Facebook

'); + $panel->appendChild('

Login or Register with Facebook

'); $panel->appendChild($facebook_auth); } diff --git a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php index 31e07687ff..cb9bab5604 100644 --- a/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php +++ b/src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php @@ -50,15 +50,15 @@ final class DifferentialRevisionCommentView extends AphrontView { $date = date('F jS, Y g:i:s A', $comment->getDateCreated()); - $author = $comment->getAuthorPHID(); - $author = $this->handles[$author]->renderLink(); + $author = $this->handles[$comment->getAuthorPHID()]; + $author_link = $author->renderLink(); $verb = DifferentialAction::getActionPastTenseVerb($comment->getAction()); $verb = phutil_escape_html($verb); $content = $comment->getContent(); if (strlen(rtrim($content))) { - $title = "{$author} {$verb} this revision:"; + $title = "{$author_link} {$verb} this revision:"; $content = '
'. $this->markupEngine->markupText($content). @@ -67,9 +67,15 @@ final class DifferentialRevisionCommentView extends AphrontView { $title = null; $content = '
'. - "

{$author} {$verb} this revision.

". + "

{$author_link} {$verb} this revision.

". '
'; } + + $background = null; + $uri = $author->getImageURI(); + if ($uri) { + $background = "background-image: url('{$uri}');"; + } return '
'. @@ -77,7 +83,7 @@ final class DifferentialRevisionCommentView extends AphrontView { '
'.$date.'
'. '
'.$title.'
'. '
'. - '
'. + '
'. '
'. '
'. $content. diff --git a/src/applications/files/controller/view/PhabricatorFileViewController.php b/src/applications/files/controller/view/PhabricatorFileViewController.php index 361a7cb98b..38e9b92654 100644 --- a/src/applications/files/controller/view/PhabricatorFileViewController.php +++ b/src/applications/files/controller/view/PhabricatorFileViewController.php @@ -52,6 +52,7 @@ class PhabricatorFileViewController extends PhabricatorFileController { $form = new AphrontFormView(); $form->setAction('/file/view/'.$file->getPHID().'/'); + $form->setUser($this->getRequest()->getUser()); $form ->appendChild( id(new AphrontFormStaticControl()) diff --git a/src/applications/people/storage/user/PhabricatorUser.php b/src/applications/people/storage/user/PhabricatorUser.php index abef89f7a4..a8180333c1 100644 --- a/src/applications/people/storage/user/PhabricatorUser.php +++ b/src/applications/people/storage/user/PhabricatorUser.php @@ -30,6 +30,12 @@ class PhabricatorUser extends PhabricatorUserDAO { protected $profileImagePHID; private $sessionKey; + + public function getProfileImagePHID() { + return nonempty( + $this->profileImagePHID, + PhabricatorEnv::getEnvConfig('user.default-profile-image-phid')); + } public function getConfiguration() { return array( diff --git a/src/applications/phid/handle/PhabricatorObjectHandle.php b/src/applications/phid/handle/PhabricatorObjectHandle.php index 5ef9dd861e..bd50f48a4a 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandle.php +++ b/src/applications/phid/handle/PhabricatorObjectHandle.php @@ -23,6 +23,7 @@ class PhabricatorObjectHandle { private $type; private $name; private $email; + private $imageURI; public function setURI($uri) { $this->uri = $uri; @@ -68,6 +69,15 @@ class PhabricatorObjectHandle { public function getEmail() { return $this->email; } + + public function setImageURI($uri) { + $this->imageURI = $uri; + return $this; + } + + public function getImageURI() { + return $this->imageURI; + } public function renderLink() { return phutil_render_tag( diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index 49f05781c9..411c93ea9d 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -58,6 +58,12 @@ class PhabricatorObjectHandleData { $handle->setName($user->getUsername()); $handle->setURI('/p/'.$user->getUsername().'/'); $handle->setEmail($user->getEmail()); + + $img_phid = $user->getProfileImagePHID(); + if ($img_phid) { + $handle->setImageURI( + PhabricatorFileURI::getViewURIForPHID($img_phid)); + } } $handles[$phid] = $handle; }