1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00
phorge-phorge/src/applications/people/controller/PhabricatorPeopleWelcomeController.php
epriestley a0ed843d47 Don't allow welcome mail to be sent to users who can't login
Summary:
Fixes T9446. We allow administrators to send "Welcome" mail to bots and mailing lists.

This is harmless (these links do not function), but confusing.

Instead, disable this option in the UI and explain why it is disabled when it is clicked. Also prevent generation of this mail lower in the stack.

Test Plan:
  - Viewed a bot page, saw action disabled, clicked it, got explanation.
  - Viewed a normal user page, saw action enabled, clicked it, sent welcome email.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9446

Differential Revision: https://secure.phabricator.com/D14134
2015-09-20 04:28:33 -07:00

53 lines
1.7 KiB
PHP

<?php
final class PhabricatorPeopleWelcomeController
extends PhabricatorPeopleController {
public function handleRequest(AphrontRequest $request) {
$admin = $this->getViewer();
$user = id(new PhabricatorPeopleQuery())
->setViewer($admin)
->withIDs(array($request->getURIData('id')))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$profile_uri = '/p/'.$user->getUsername().'/';
if (!$user->canEstablishWebSessions()) {
return $this->newDialog()
->setTitle(pht('Not a Normal User'))
->appendParagraph(
pht(
'You can not send this user a welcome mail because they are not '.
'a normal user and can not log in to the web interface. Special '.
'users (like bots and mailing lists) are unable to establish web '.
'sessions.'))
->addCancelButton($profile_uri, pht('Done'));
}
if ($request->isFormPost()) {
$user->sendWelcomeEmail($admin);
return id(new AphrontRedirectResponse())->setURI($profile_uri);
}
return $this->newDialog()
->setTitle(pht('Send Welcome Email'))
->appendParagraph(
pht(
'This will send the user another copy of the "Welcome to '.
'Phabricator" email that users normally receive when their '.
'accounts are created.'))
->appendParagraph(
pht(
'The email contains a link to log in to their account. Sending '.
'another copy of the email can be useful if the original was lost '.
'or never sent.'))
->appendParagraph(pht('The email will identify you as the sender.'))
->addSubmitButton(pht('Send Email'))
->addCancelButton($profile_uri);
}
}