Differential D21765 Diff 51901 src/applications/auth/controller/PhabricatorAuthRegisterController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/controller/PhabricatorAuthRegisterController.php
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
if ($invite) { | if ($invite) { | ||||
$default_email = $invite->getEmailAddress(); | $default_email = $invite->getEmailAddress(); | ||||
} | } | ||||
if ($default_email !== null) { | if ($default_email !== null) { | ||||
if (!PhabricatorUserEmail::isValidAddress($default_email)) { | if (!PhabricatorUserEmail::isValidAddress($default_email)) { | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'The email address associated with this external account ("%s") is '. | 'The email address associated with this external account ("%s") is '. | ||||
'not a valid email address and can not be used to register a '. | 'not a valid email address and can not be used to register an '. | ||||
'Phabricator account. Choose a different, valid address.', | 'account. Choose a different, valid address.', | ||||
phutil_tag('strong', array(), $default_email)); | phutil_tag('strong', array(), $default_email)); | ||||
$default_email = null; | $default_email = null; | ||||
} | } | ||||
} | } | ||||
if ($default_email !== null) { | if ($default_email !== null) { | ||||
// We should bypass policy here because e.g. limiting an application use | // We should bypass policy here because e.g. limiting an application use | ||||
// to a subset of users should not allow the others to overwrite | // to a subset of users should not allow the others to overwrite | ||||
// configured application emails. | // configured application emails. | ||||
$application_email = id(new PhabricatorMetaMTAApplicationEmailQuery()) | $application_email = id(new PhabricatorMetaMTAApplicationEmailQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withAddresses(array($default_email)) | ->withAddresses(array($default_email)) | ||||
->executeOne(); | ->executeOne(); | ||||
if ($application_email) { | if ($application_email) { | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'The email address associated with this account ("%s") is '. | 'The email address associated with this account ("%s") is '. | ||||
'already in use by an application and can not be used to '. | 'already in use by an application and can not be used to '. | ||||
'register a new Phabricator account. Choose a different, valid '. | 'register a new account. Choose a different, valid address.', | ||||
'address.', | |||||
phutil_tag('strong', array(), $default_email)); | phutil_tag('strong', array(), $default_email)); | ||||
$default_email = null; | $default_email = null; | ||||
} | } | ||||
} | } | ||||
$show_existing = null; | $show_existing = null; | ||||
if ($default_email !== null) { | if ($default_email !== null) { | ||||
// If the account source provided an email, but it's not allowed by | // If the account source provided an email, but it's not allowed by | ||||
// the configuration, roadblock the user. Previously, we let the user | // the configuration, roadblock the user. Previously, we let the user | ||||
// pick a valid email address instead, but this does not align well with | // pick a valid email address instead, but this does not align well with | ||||
// user expectation and it's not clear the cases it enables are valuable. | // user expectation and it's not clear the cases it enables are valuable. | ||||
// See discussion in T3472. | // See discussion in T3472. | ||||
if (!PhabricatorUserEmail::isAllowedAddress($default_email)) { | if (!PhabricatorUserEmail::isAllowedAddress($default_email)) { | ||||
$debug_email = new PHUIInvisibleCharacterView($default_email); | $debug_email = new PHUIInvisibleCharacterView($default_email); | ||||
return $this->renderError( | return $this->renderError( | ||||
array( | array( | ||||
pht( | pht( | ||||
'The account you are attempting to register with has an invalid '. | 'The account you are attempting to register with has an invalid '. | ||||
'email address (%s). This Phabricator install only allows '. | 'email address (%s). This server only allows registration with '. | ||||
'registration with specific email addresses:', | 'specific email addresses:', | ||||
$debug_email), | $debug_email), | ||||
phutil_tag('br'), | phutil_tag('br'), | ||||
phutil_tag('br'), | phutil_tag('br'), | ||||
PhabricatorUserEmail::describeAllowedAddresses(), | PhabricatorUserEmail::describeAllowedAddresses(), | ||||
)); | )); | ||||
} | } | ||||
// If the account source provided an email, but another account already | // If the account source provided an email, but another account already | ||||
Show All 17 Lines | public function handleRequest(AphrontRequest $request) { | ||||
if ($show_existing !== null) { | if ($show_existing !== null) { | ||||
if (!$request->getInt('phase')) { | if (!$request->getInt('phase')) { | ||||
return $this->newDialog() | return $this->newDialog() | ||||
->setTitle(pht('Email Address Already in Use')) | ->setTitle(pht('Email Address Already in Use')) | ||||
->addHiddenInput('phase', 1) | ->addHiddenInput('phase', 1) | ||||
->appendParagraph( | ->appendParagraph( | ||||
pht( | pht( | ||||
'You are creating a new Phabricator account linked to an '. | 'You are creating a new account linked to an existing '. | ||||
'existing external account from outside Phabricator.')) | 'external account.')) | ||||
->appendParagraph( | ->appendParagraph( | ||||
pht( | pht( | ||||
'The email address ("%s") associated with the external account '. | 'The email address ("%s") associated with the external account '. | ||||
'is already in use by an existing Phabricator account. Multiple '. | 'is already in use by an existing %s account. Multiple '. | ||||
'Phabricator accounts may not have the same email address, so '. | '%s accounts may not have the same email address, so '. | ||||
'you can not use this email address to register a new '. | 'you can not use this email address to register a new account.', | ||||
'Phabricator account.', | phutil_tag('strong', array(), $show_existing), | ||||
phutil_tag('strong', array(), $show_existing))) | PlatformSymbols::getPlatformServerName(), | ||||
PlatformSymbols::getPlatformServerName())) | |||||
->appendParagraph( | ->appendParagraph( | ||||
pht( | pht( | ||||
'If you want to register a new account, continue with this '. | 'If you want to register a new account, continue with this '. | ||||
'registration workflow and choose a new, unique email address '. | 'registration workflow and choose a new, unique email address '. | ||||
'for the new account.')) | 'for the new account.')) | ||||
->appendParagraph( | ->appendParagraph( | ||||
pht( | pht( | ||||
'If you want to link an existing Phabricator account to this '. | 'If you want to link an existing %s account to this '. | ||||
'external account, do not continue. Instead: log in to your '. | 'external account, do not continue. Instead: log in to your '. | ||||
'existing account, then go to "Settings" and link the account '. | 'existing account, then go to "Settings" and link the account '. | ||||
'in the "External Accounts" panel.')) | 'in the "External Accounts" panel.', | ||||
PlatformSymbols::getPlatformServerName())) | |||||
->appendParagraph( | ->appendParagraph( | ||||
pht( | pht( | ||||
'If you continue, you will create a new account. You will not '. | 'If you continue, you will create a new account. You will not '. | ||||
'be able to link this external account to an existing account.')) | 'be able to link this external account to an existing account.')) | ||||
->addCancelButton('/auth/login/', pht('Cancel')) | ->addCancelButton('/auth/login/', pht('Cancel')) | ||||
->addSubmitButton(pht('Create New Account')); | ->addSubmitButton(pht('Create New Account')); | ||||
} else { | } else { | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'The external account you are registering with has an email address '. | 'The external account you are registering with has an email address '. | ||||
'that is already in use ("%s") by an existing Phabricator account. '. | 'that is already in use ("%s") by an existing %s account. '. | ||||
'Choose a new, valid email address to register a new Phabricator '. | 'Choose a new, valid email address to register a new account.', | ||||
'account.', | phutil_tag('strong', array(), $show_existing), | ||||
phutil_tag('strong', array(), $show_existing)); | PlatformSymbols::getPlatformServerName()); | ||||
} | } | ||||
} | } | ||||
$profile = id(new PhabricatorRegistrationProfile()) | $profile = id(new PhabricatorRegistrationProfile()) | ||||
->setDefaultUsername($default_username) | ->setDefaultUsername($default_username) | ||||
->setDefaultEmail($default_email) | ->setDefaultEmail($default_email) | ||||
->setDefaultRealName($default_realname) | ->setDefaultRealName($default_realname) | ||||
->setCanEditUsername(true) | ->setCanEditUsername(true) | ||||
▲ Show 20 Lines • Show All 388 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
$form->appendChild($submit); | $form->appendChild($submit); | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
if ($is_setup) { | if ($is_setup) { | ||||
$crumbs->addTextCrumb(pht('Setup Admin Account')); | $crumbs->addTextCrumb(pht('Setup Admin Account')); | ||||
$title = pht('Welcome to Phabricator'); | $title = pht( | ||||
'Welcome to %s', | |||||
PlatformSymbols::getPlatformServerName()); | |||||
} else { | } else { | ||||
$crumbs->addTextCrumb(pht('Register')); | $crumbs->addTextCrumb(pht('Register')); | ||||
$crumbs->addTextCrumb($provider->getProviderName()); | $crumbs->addTextCrumb($provider->getProviderName()); | ||||
$title = pht('Create a New Account'); | $title = pht('Create a New Account'); | ||||
} | } | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$welcome_view = null; | $welcome_view = null; | ||||
if ($is_setup) { | if ($is_setup) { | ||||
$welcome_view = id(new PHUIInfoView()) | $welcome_view = id(new PHUIInfoView()) | ||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | ||||
->setTitle(pht('Welcome to Phabricator')) | ->setTitle( | ||||
pht( | |||||
'Welcome to %s', | |||||
PlatformSymbols::getPlatformServerName())) | |||||
->appendChild( | ->appendChild( | ||||
pht( | pht( | ||||
'Installation is complete. Register your administrator account '. | 'Installation is complete. Register your administrator account '. | ||||
'below to log in. You will be able to configure options and add '. | 'below to log in. You will be able to configure options and add '. | ||||
'authentication mechanisms later on.')); | 'authentication mechanisms later on.')); | ||||
} | } | ||||
$object_box = id(new PHUIObjectBoxView()) | $object_box = id(new PHUIObjectBoxView()) | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | final class PhabricatorAuthRegisterController | ||||
protected function renderError($message) { | protected function renderError($message) { | ||||
return $this->renderErrorPage( | return $this->renderErrorPage( | ||||
pht('Registration Failed'), | pht('Registration Failed'), | ||||
array($message)); | array($message)); | ||||
} | } | ||||
private function sendWaitingForApprovalEmail(PhabricatorUser $user) { | private function sendWaitingForApprovalEmail(PhabricatorUser $user) { | ||||
$title = '[Phabricator] '.pht( | $title = pht( | ||||
'New User "%s" Awaiting Approval', | '[%s] New User "%s" Awaiting Approval', | ||||
PlatformSymbols::getPlatformServerName(), | |||||
$user->getUsername()); | $user->getUsername()); | ||||
$body = new PhabricatorMetaMTAMailBody(); | $body = new PhabricatorMetaMTAMailBody(); | ||||
$body->addRawSection( | $body->addRawSection( | ||||
pht( | pht( | ||||
'Newly registered user "%s" is awaiting account approval by an '. | 'Newly registered user "%s" is awaiting account approval by an '. | ||||
'administrator.', | 'administrator.', | ||||
Show All 29 Lines |