mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-02 19:52:44 +01:00
2c713b2d25
Summary: Ref T13222. Long ago, we had a Config option (`welcome.html`) to let you dump HTML onto the login screen, but this was relatively hard to use and not good from a security perspective. In some cases this was obsoleted by Dashboards, but there's at least some remaining set of use cases for actual login instructions on the login screen. For example, WMF has some guidance on //which// SSO mechanism to use based on what types of account you have. On `secure`, users assume they can register by clicking "Log In With GitHub" or whatever, and it might reduce frustration to tell them upfront that registration is closed. Some other types of auth messaging could also either use customization or defaults (e.g., the invite/welcome/approve mail). We could do this with a bunch of Config options, but I'd generally like to move to a world where there's less stuff in Config and more configuration is contextual. I think it tends to be easier to use, and we get a lot of fringe benefits (granular permissions, API, normal transaction logs, more abililty to customize workflows and provide contextual help/hints, etc). Here, for example, we can provide a remarkup preview, which would be trickier with Config. This does not actually do anything yet. Test Plan: {F6137541} Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13222 Differential Revision: https://secure.phabricator.com/D19992
108 lines
2.5 KiB
PHP
108 lines
2.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorAuthMessageEditEngine
|
|
extends PhabricatorEditEngine {
|
|
|
|
private $messageType;
|
|
|
|
const ENGINECONST = 'auth.message';
|
|
|
|
public function isEngineConfigurable() {
|
|
return false;
|
|
}
|
|
|
|
public function getEngineName() {
|
|
return pht('Auth Messages');
|
|
}
|
|
|
|
public function getSummaryHeader() {
|
|
return pht('Edit Auth Messages');
|
|
}
|
|
|
|
public function getSummaryText() {
|
|
return pht('This engine is used to edit authentication messages.');
|
|
}
|
|
|
|
public function getEngineApplicationClass() {
|
|
return 'PhabricatorAuthApplication';
|
|
}
|
|
|
|
public function setMessageType(PhabricatorAuthMessageType $type) {
|
|
$this->messageType = $type;
|
|
return $this;
|
|
}
|
|
|
|
public function getMessageType() {
|
|
return $this->messageType;
|
|
}
|
|
|
|
protected function newEditableObject() {
|
|
$type = $this->getMessageType();
|
|
|
|
if ($type) {
|
|
$message = PhabricatorAuthMessage::initializeNewMessage($type);
|
|
} else {
|
|
$message = new PhabricatorAuthMessage();
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
|
|
protected function newObjectQuery() {
|
|
return new PhabricatorAuthMessageQuery();
|
|
}
|
|
|
|
protected function getObjectCreateTitleText($object) {
|
|
return pht('Create Auth Message');
|
|
}
|
|
|
|
protected function getObjectCreateButtonText($object) {
|
|
return pht('Create Auth Message');
|
|
}
|
|
|
|
protected function getObjectEditTitleText($object) {
|
|
return pht('Edit Auth Message');
|
|
}
|
|
|
|
protected function getObjectEditShortText($object) {
|
|
return $object->getObjectName();
|
|
}
|
|
|
|
protected function getObjectCreateShortText() {
|
|
return pht('Create Auth Message');
|
|
}
|
|
|
|
protected function getObjectName() {
|
|
return pht('Auth Message');
|
|
}
|
|
|
|
protected function getEditorURI() {
|
|
return '/auth/message/edit/';
|
|
}
|
|
|
|
protected function getObjectCreateCancelURI($object) {
|
|
return '/auth/message/';
|
|
}
|
|
|
|
protected function getObjectViewURI($object) {
|
|
return $object->getURI();
|
|
}
|
|
|
|
protected function getCreateNewObjectPolicy() {
|
|
return $this->getApplication()->getPolicy(
|
|
AuthManageProvidersCapability::CAPABILITY);
|
|
}
|
|
|
|
protected function buildCustomEditFields($object) {
|
|
return array(
|
|
id(new PhabricatorRemarkupEditField())
|
|
->setKey('messageText')
|
|
->setTransactionType(
|
|
PhabricatorAuthMessageTextTransaction::TRANSACTIONTYPE)
|
|
->setLabel(pht('Message Text'))
|
|
->setDescription(pht('Custom text for the message.'))
|
|
->setValue($object->getMessageText()),
|
|
);
|
|
}
|
|
|
|
}
|