@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Explicitly warn the user multiple times when they try to register an external account with an existing email

Summary: Ref T3472. Ref T12113. This implements the gigantic roadblock nonsense in T3472.

Test Plan: {F2425916}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12113, T3472

Differential Revision: https://secure.phabricator.com/D17212

+74 -10
+74 -10
src/applications/auth/controller/PhabricatorAuthRegisterController.php
··· 54 54 } 55 55 } 56 56 57 + $errors = array(); 58 + 57 59 $user = new PhabricatorUser(); 58 60 59 61 $default_username = $account->getUsername(); ··· 65 67 $default_email = $invite->getEmailAddress(); 66 68 } 67 69 68 - if (!PhabricatorUserEmail::isValidAddress($default_email)) { 69 - $default_email = null; 70 + if ($default_email !== null) { 71 + if (!PhabricatorUserEmail::isValidAddress($default_email)) { 72 + $errors[] = pht( 73 + 'The email address associated with this external account ("%s") is '. 74 + 'not a valid email address and can not be used to register a '. 75 + 'Phabricator account. Choose a different, valid address.', 76 + phutil_tag('strong', array(), $default_email)); 77 + $default_email = null; 78 + } 70 79 } 71 80 72 81 if ($default_email !== null) { 73 82 // We should bypass policy here becase e.g. limiting an application use 74 83 // to a subset of users should not allow the others to overwrite 75 - // configured application emails 84 + // configured application emails. 76 85 $application_email = id(new PhabricatorMetaMTAApplicationEmailQuery()) 77 86 ->setViewer(PhabricatorUser::getOmnipotentUser()) 78 87 ->withAddresses(array($default_email)) 79 88 ->executeOne(); 80 89 if ($application_email) { 90 + $errors[] = pht( 91 + 'The email address associated with this account ("%s") is '. 92 + 'already in use by an application and can not be used to '. 93 + 'register a new Phabricator account. Choose a different, valid '. 94 + 'address.', 95 + phutil_tag('strong', array(), $default_email)); 81 96 $default_email = null; 82 97 } 83 98 } 84 99 100 + $show_existing = null; 85 101 if ($default_email !== null) { 86 102 // If the account source provided an email, but it's not allowed by 87 103 // the configuration, roadblock the user. Previously, we let the user ··· 105 121 106 122 // If the account source provided an email, but another account already 107 123 // has that email, just pretend we didn't get an email. 108 - 109 - // TODO: See T3472. 110 - 111 124 if ($default_email !== null) { 112 125 $same_email = id(new PhabricatorUserEmail())->loadOneWhere( 113 126 'address = %s', ··· 118 131 // invite means that the address is nonprimary and unverified and 119 132 // we're OK to steal it. 120 133 } else { 134 + $show_existing = $default_email; 121 135 $default_email = null; 122 136 } 123 137 } 124 138 } 125 139 } 126 140 141 + if ($show_existing !== null) { 142 + if (!$request->getInt('phase')) { 143 + return $this->newDialog() 144 + ->setTitle(pht('Email Address Already in Use')) 145 + ->addHiddenInput('phase', 1) 146 + ->appendParagraph( 147 + pht( 148 + 'You are creating a new Phabricator account linked to an '. 149 + 'existing external account from outside Phabricator.')) 150 + ->appendParagraph( 151 + pht( 152 + 'The email address ("%s") associated with the external account '. 153 + 'is already in use by an existing Phabricator account. Multiple '. 154 + 'Phabricator accounts may not have the same email address, so '. 155 + 'you can not use this email address to register a new '. 156 + 'Phabricator account.', 157 + phutil_tag('strong', array(), $show_existing))) 158 + ->appendParagraph( 159 + pht( 160 + 'If you want to register a new account, continue with this '. 161 + 'registration workflow and choose a new, unique email address '. 162 + 'for the new account.')) 163 + ->appendParagraph( 164 + pht( 165 + 'If you want to link an existing Phabricator account to this '. 166 + 'external account, do not continue. Instead: log in to your '. 167 + 'existing account, then go to "Settings" and link the account '. 168 + 'in the "External Accounts" panel.')) 169 + ->appendParagraph( 170 + pht( 171 + 'If you continue, you will create a new account. You will not '. 172 + 'be able to link this external account to an existing account.')) 173 + ->addCancelButton('/auth/login/', pht('Cancel')) 174 + ->addSubmitButton(pht('Create New Account')); 175 + } else { 176 + $errors[] = pht( 177 + 'The external account you are registering with has an email address '. 178 + 'that is already in use ("%s") by an existing Phabricator account. '. 179 + 'Choose a new, valid email address to register a new Phabricator '. 180 + 'account.', 181 + phutil_tag('strong', array(), $show_existing)); 182 + } 183 + } 184 + 127 185 $profile = id(new PhabricatorRegistrationProfile()) 128 186 ->setDefaultUsername($default_username) 129 187 ->setDefaultEmail($default_email) ··· 167 225 $value_email = $default_email; 168 226 $value_password = null; 169 227 170 - $errors = array(); 171 - 172 228 $require_real_name = PhabricatorEnv::getEnvConfig('user.require-real-name'); 173 229 174 230 $e_username = strlen($value_username) ? null : true; ··· 193 249 $e_username = null; 194 250 } 195 251 196 - if (($request->isFormPost() || !$can_edit_anything) && !$from_invite) { 252 + $try_register = 253 + ($request->isFormPost() || !$can_edit_anything) && 254 + !$from_invite && 255 + ($request->getInt('phase') != 1); 256 + 257 + if ($try_register) { 258 + $errors = array(); 259 + 197 260 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 198 261 199 262 if ($must_set_password && !$skip_captcha) { ··· 402 465 } 403 466 404 467 $form = id(new AphrontFormView()) 405 - ->setUser($request->getUser()); 468 + ->setUser($request->getUser()) 469 + ->addHiddenInput('phase', 2); 406 470 407 471 if (!$is_default) { 408 472 $form->appendChild(