From 6eb02af314a47dffa440af8cb2989e22726079df Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Nov 2013 10:36:00 -0800 Subject: [PATCH] Allow "bin/auth recover" to succeed before phabricator.base-uri is set Summary: Fixes T4132. If you run "bin/auth recover" before setting the base URI, it throws when trying to generate a production URI. Instead, just show the path. We can't figure out the domain, and I think this is less confusing than showing "your.phabricator.example.com", etc. Test Plan: Ran `bin/auth recover ` for valid and missing base-uri. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4132 Differential Revision: https://secure.phabricator.com/D7615 --- .../PhabricatorAuthManagementRecoverWorkflow.php | 3 ++- src/applications/people/storage/PhabricatorUser.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php b/src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php index 99e7fa0178..8013b39390 100644 --- a/src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php +++ b/src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php @@ -72,7 +72,8 @@ final class PhabricatorAuthManagementRecoverWorkflow $console = PhutilConsole::getConsole(); $console->writeOut( pht( - 'Use this link to recover access to the "%s" account:', + 'Use this link to recover access to the "%s" account from the web '. + 'interface:', $username)); $console->writeOut("\n\n"); $console->writeOut(" %s", $user->getEmailLoginURI()); diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 974a60b2bb..aecd0e4357 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -495,8 +495,18 @@ final class PhabricatorUser } } $token = $this->generateEmailToken($email); - $uri = PhabricatorEnv::getProductionURI('/login/etoken/'.$token.'/'); + + $uri = '/login/etoken/'.$token.'/'; + try { + $uri = PhabricatorEnv::getProductionURI($uri); + } catch (Exception $ex) { + // If a user runs `bin/auth recover` before configuring the base URI, + // just show the path. We don't have any way to figure out the domain. + // See T4132. + } + $uri = new PhutilURI($uri); + return $uri->alter('email', $email->getAddress()); }