mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Allow Auth messages to have detailed descriptions and default values, then give "Email Login" both
Summary: Depends on D20664. Ref T13343. There's a reasonable value for the default "Email Login" auth message (generic "you reset your password" text) that installs may reasonably want to replace. Add support for a default value. Also, since it isn't completely obvious where this message shows up, add support for an extended description and explain what's going on in more detail. Test Plan: - Viewed message detail page, saw more detailed information. - Sent mail (got default), overrode message and sent mail (got custom message), deleted message (got default again). Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13343 Differential Revision: https://secure.phabricator.com/D20665
This commit is contained in:
parent
38d30af362
commit
ced416cc73
5 changed files with 64 additions and 11 deletions
|
@ -97,20 +97,35 @@ final class PhabricatorAuthMessageViewController
|
|||
private function buildPropertiesView(PhabricatorAuthMessage $message) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$message_type = $message->getMessageType();
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setViewer($viewer);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Description'),
|
||||
$message->getMessageType()->getShortDescription());
|
||||
$full_description = $message_type->getFullDescription();
|
||||
if (strlen($full_description)) {
|
||||
$view->addTextContent(new PHUIRemarkupView($viewer, $full_description));
|
||||
} else {
|
||||
$short_description = $message_type->getShortDescription();
|
||||
$view->addProperty(pht('Description'), $short_description);
|
||||
}
|
||||
|
||||
if (strlen($message->getMessageText())) {
|
||||
$message_text = $message->getMessageText();
|
||||
if (strlen($message_text)) {
|
||||
$view->addSectionHeader(
|
||||
pht('Message Preview'),
|
||||
PHUIPropertyListView::ICON_SUMMARY);
|
||||
|
||||
$view->addTextContent(
|
||||
new PHUIRemarkupView($viewer, $message->getMessageText()));
|
||||
$view->addTextContent(new PHUIRemarkupView($viewer, $message_text));
|
||||
}
|
||||
|
||||
$default_text = $message_type->getDefaultMessageText();
|
||||
if (strlen($default_text)) {
|
||||
$view->addSectionHeader(
|
||||
pht('Default Message'),
|
||||
PHUIPropertyListView::ICON_SUMMARY);
|
||||
|
||||
$view->addTextContent(new PHUIRemarkupView($viewer, $default_text));
|
||||
}
|
||||
|
||||
return $view;
|
||||
|
|
|
@ -15,4 +15,27 @@ final class PhabricatorAuthEmailLoginMessageType
|
|||
'to access their account.');
|
||||
}
|
||||
|
||||
public function getFullDescription() {
|
||||
return pht(
|
||||
'Guidance included in the mail message body when users request an '.
|
||||
'email link to access their account.'.
|
||||
"\n\n".
|
||||
'For installs with password authentication enabled, users access this '.
|
||||
'workflow by using the "Forgot your password?" link on the login '.
|
||||
'screen.'.
|
||||
"\n\n".
|
||||
'For installs without password authentication enabled, users access '.
|
||||
'this workflow by using the "Send a login link to your email address." '.
|
||||
'link on the login screen. This workflow allows users to recover '.
|
||||
'access to their account if there is an issue with an external '.
|
||||
'login service.');
|
||||
}
|
||||
|
||||
public function getDefaultMessageText() {
|
||||
return pht(
|
||||
'You (or someone pretending to be you) recently requested an account '.
|
||||
'recovery link be sent to this email address. If you did not make '.
|
||||
'this request, you can ignore this message.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,4 +30,12 @@ abstract class PhabricatorAuthMessageType
|
|||
abstract public function getDisplayName();
|
||||
abstract public function getShortDescription();
|
||||
|
||||
public function getFullDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDefaultMessageText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,12 +75,16 @@ final class PhabricatorAuthMessage
|
|||
$message_key) {
|
||||
|
||||
$message = self::loadMessage($viewer, $message_key);
|
||||
|
||||
if (!$message) {
|
||||
return null;
|
||||
if ($message) {
|
||||
$message_text = $message->getMessageText();
|
||||
if (strlen($message_text)) {
|
||||
return $message_text;
|
||||
}
|
||||
}
|
||||
|
||||
return $message->getMessageText();
|
||||
$message_type = PhabricatorAuthMessageType::newFromKey($message_key);
|
||||
|
||||
return $message_type->getDefaultMessageText();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -90,7 +90,10 @@ abstract class PhabricatorPeopleMailEngine
|
|||
->setConfig('uri.base', PhabricatorEnv::getProductionURI('/'))
|
||||
->setMode(PhutilRemarkupEngine::MODE_TEXT);
|
||||
|
||||
return $engine->markupText($text);
|
||||
$rendered_text = $engine->markupText($text);
|
||||
$rendered_text = rtrim($rendered_text, "\n");
|
||||
|
||||
return $rendered_text;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue