From 870f4bfe73d9d0bccc425115900a14efa1aee8a6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 6 May 2011 17:01:00 -0700 Subject: [PATCH] Fix GitHub OAuth Registration for users without a name Summary: Github allows you to have an account without a real name. The OAuth controller actually handles this fine, mostly, except that it calls a bogus method. Also there is some null vs empty string confusion. Test Plan: Deleted my name on Github and then registered for an account on Phabricator. Reviewed By: tuomaspelkonen Reviewers: jungejason, tuomaspelkonen, aran CC: anjali, aran, tuomaspelkonen Differential Revision: 247 --- .../default/PhabricatorOAuthDefaultRegistrationController.php | 4 ++-- .../oauth/provider/github/PhabricatorOAuthProviderGithub.php | 4 ++-- src/applications/auth/oauth/provider/github/__init__.php | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/applications/auth/controller/oauthregistration/default/PhabricatorOAuthDefaultRegistrationController.php b/src/applications/auth/controller/oauthregistration/default/PhabricatorOAuthDefaultRegistrationController.php index 816092c6dd..a748c3e274 100644 --- a/src/applications/auth/controller/oauthregistration/default/PhabricatorOAuthDefaultRegistrationController.php +++ b/src/applications/auth/controller/oauthregistration/default/PhabricatorOAuthDefaultRegistrationController.php @@ -60,9 +60,9 @@ class PhabricatorOAuthDefaultRegistrationController } } - if ($user->getRealName() === null) { + if (!strlen($user->getRealName())) { $user->setRealName($request->getStr('realname')); - if (!strlen($user->getStr('realname'))) { + if (!strlen($user->getRealName())) { $e_realname = 'Required'; $errors[] = 'Real name is required.'; } else { diff --git a/src/applications/auth/oauth/provider/github/PhabricatorOAuthProviderGithub.php b/src/applications/auth/oauth/provider/github/PhabricatorOAuthProviderGithub.php index f5834369ae..f6e9759d19 100644 --- a/src/applications/auth/oauth/provider/github/PhabricatorOAuthProviderGithub.php +++ b/src/applications/auth/oauth/provider/github/PhabricatorOAuthProviderGithub.php @@ -78,7 +78,7 @@ class PhabricatorOAuthProviderGithub extends PhabricatorOAuthProvider { } public function retrieveUserEmail() { - return $this->userData['email']; + return idx($this->userData, 'email'); } public function retrieveUserAccountName() { @@ -103,7 +103,7 @@ class PhabricatorOAuthProviderGithub extends PhabricatorOAuthProvider { } public function retrieveUserRealName() { - return $this->userData['name']; + return idx($this->userData, 'name'); } } diff --git a/src/applications/auth/oauth/provider/github/__init__.php b/src/applications/auth/oauth/provider/github/__init__.php index b6e86d3f52..6c17b44365 100644 --- a/src/applications/auth/oauth/provider/github/__init__.php +++ b/src/applications/auth/oauth/provider/github/__init__.php @@ -9,5 +9,7 @@ phutil_require_module('phabricator', 'applications/auth/oauth/provider/base'); phutil_require_module('phabricator', 'infrastructure/env'); +phutil_require_module('phutil', 'utils'); + phutil_require_source('PhabricatorOAuthProviderGithub.php');