Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/auth/controller/PhabricatorLogoutController.php b/src/applications/auth/controller/PhabricatorLogoutController.php
index dccf6bb45b..d71d080cbd 100644
--- a/src/applications/auth/controller/PhabricatorLogoutController.php
+++ b/src/applications/auth/controller/PhabricatorLogoutController.php
@@ -1,82 +1,112 @@
<?php
final class PhabricatorLogoutController
extends PhabricatorAuthController {
public function shouldRequireLogin() {
// See T13310. We allow access to the "Logout" controller even if you are
// not logged in: otherwise, users who do not have access to any Spaces can
// not log out.
// When you try to access a controller which requires you be logged in,
// and you do not have access to any Spaces, an access check fires first
// and prevents access with a "No Access to Spaces" error. If this
// controller requires users be logged in, users who are trying to log out
// and also have no access to Spaces get the error instead of a logout
// workflow and are trapped.
// By permitting access to this controller even if you are not logged in,
// we bypass the Spaces check and allow users who have no access to Spaces
// to log out.
// This incidentally allows users who are already logged out to access the
// controller, but this is harmless: we just no-op these requests.
return false;
}
public function shouldRequireEmailVerification() {
// Allow unverified users to logout.
return false;
}
public function shouldRequireEnabledUser() {
// Allow disabled users to logout.
return false;
}
public function shouldAllowPartialSessions() {
return true;
}
public function shouldAllowLegallyNonCompliantUsers() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
if ($request->isFormPost()) {
// Destroy the user's session in the database so logout works even if
// their cookies have some issues. We'll detect cookie issues when they
// try to login again and tell them to clear any junk.
$phsid = $request->getCookie(PhabricatorCookies::COOKIE_SESSION);
if (strlen($phsid)) {
$session = id(new PhabricatorAuthSessionQuery())
->setViewer($viewer)
->withSessionKeys(array($phsid))
->executeOne();
if ($session) {
$engine = new PhabricatorAuthSessionEngine();
$engine->logoutSession($viewer, $session);
}
}
$request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
return id(new AphrontRedirectResponse())
->setURI('/auth/loggedout/');
}
+
if ($viewer->getPHID()) {
- return $this->newDialog()
+ $dialog = $this->newDialog()
->setTitle(pht('Log Out?'))
- ->appendChild(pht('Are you sure you want to log out?'))
- ->addSubmitButton(pht('Log Out'))
+ ->appendParagraph(pht('Are you sure you want to log out?'))
->addCancelButton('/');
+
+ $configs = id(new PhabricatorAuthProviderConfigQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->execute();
+ if (!$configs) {
+ $dialog
+ ->appendRemarkup(
+ pht(
+ 'WARNING: You have not configured any authentication providers '.
+ 'yet, so your account has no login credentials. If you log out '.
+ 'now, you will not be able to log back in normally.'))
+ ->appendParagraph(
+ pht(
+ 'To enable the login flow, follow setup guidance and configure '.
+ 'at least one authentication provider, then associate '.
+ 'credentials with your account. After completing these steps, '.
+ 'you will be able to log out and log back in normally.'))
+ ->appendParagraph(
+ pht(
+ 'If you log out now, you can still regain access to your '.
+ 'account later by using the account recovery workflow. The '.
+ 'login screen will prompt you with recovery instructions.'));
+
+ $button = pht('Log Out Anyway');
+ } else {
+ $button = pht('Log Out');
+ }
+
+ $dialog->addSubmitButton($button);
+ return $dialog;
}
return id(new AphrontRedirectResponse())->setURI('/');
}
}
diff --git a/src/applications/auth/controller/config/PhabricatorAuthListController.php b/src/applications/auth/controller/config/PhabricatorAuthListController.php
index 5d1d85cca6..b25c791e27 100644
--- a/src/applications/auth/controller/config/PhabricatorAuthListController.php
+++ b/src/applications/auth/controller/config/PhabricatorAuthListController.php
@@ -1,122 +1,122 @@
<?php
final class PhabricatorAuthListController
extends PhabricatorAuthProviderConfigController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$configs = id(new PhabricatorAuthProviderConfigQuery())
->setViewer($viewer)
->execute();
$list = new PHUIObjectItemListView();
$can_manage = $this->hasApplicationCapability(
AuthManageProvidersCapability::CAPABILITY);
$is_locked = PhabricatorEnv::getEnvConfig('auth.lock-config');
foreach ($configs as $config) {
$item = new PHUIObjectItemView();
$id = $config->getID();
$view_uri = $config->getURI();
$provider = $config->getProvider();
$name = $provider->getProviderName();
$item
->setHeader($name)
->setHref($view_uri);
$domain = $provider->getProviderDomain();
if ($domain !== 'self') {
$item->addAttribute($domain);
}
if ($config->getShouldAllowRegistration()) {
$item->addAttribute(pht('Allows Registration'));
} else {
$item->addAttribute(pht('Does Not Allow Registration'));
}
if ($config->getIsEnabled()) {
$item->setStatusIcon('fa-check-circle green');
} else {
$item->setStatusIcon('fa-ban red');
$item->addIcon('fa-ban grey', pht('Disabled'));
}
$list->addItem($item);
}
$list->setNoDataString(
pht(
'%s You have not added authentication providers yet. Use "%s" to add '.
'a provider, which will let users register new Phabricator accounts '.
'and log in.',
phutil_tag(
'strong',
array(),
pht('No Providers Configured:')),
phutil_tag(
'a',
array(
'href' => $this->getApplicationURI('config/new/'),
),
- pht('Add Authentication Provider'))));
+ pht('Add Provider'))));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Login and Registration'));
$crumbs->setBorder(true);
$guidance_context = id(new PhabricatorAuthProvidersGuidanceContext())
->setCanManage($can_manage);
$guidance = id(new PhabricatorGuidanceEngine())
->setViewer($viewer)
->setGuidanceContext($guidance_context)
->newInfoView();
$is_disabled = (!$can_manage || $is_locked);
$button = id(new PHUIButtonView())
->setTag('a')
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->setIcon('fa-plus')
->setDisabled($is_disabled)
->setWorkflow($is_disabled)
->setHref($this->getApplicationURI('config/new/'))
->setText(pht('Add Provider'));
$list->setFlush(true);
$list = id(new PHUIObjectBoxView())
->setHeaderText(pht('Providers'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->appendChild($list);
$title = pht('Login and Registration Providers');
$header = id(new PHUIHeaderView())
->setHeader($title)
->setHeaderIcon('fa-key')
->addActionLink($button);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(
array(
$guidance,
$list,
));
$nav = $this->newNavigation()
->setCrumbs($crumbs)
->appendChild($view);
$nav->selectFilter('login');
return $this->newPage()
->setTitle($title)
->appendChild($nav);
}
}
diff --git a/src/view/AphrontDialogView.php b/src/view/AphrontDialogView.php
index 09fc8e7a16..b8b00a6b3e 100644
--- a/src/view/AphrontDialogView.php
+++ b/src/view/AphrontDialogView.php
@@ -1,456 +1,470 @@
<?php
final class AphrontDialogView
extends AphrontView
implements AphrontResponseProducerInterface {
private $title;
private $shortTitle;
private $submitButton;
private $cancelURI;
private $cancelText = 'Cancel';
private $submitURI;
private $hidden = array();
private $class;
private $renderAsForm = true;
private $formID;
private $footers = array();
private $isStandalone;
private $method = 'POST';
private $disableWorkflowOnSubmit;
private $disableWorkflowOnCancel;
private $width = 'default';
private $errors = array();
private $flush;
private $validationException;
private $objectList;
private $resizeX;
private $resizeY;
const WIDTH_DEFAULT = 'default';
const WIDTH_FORM = 'form';
const WIDTH_FULL = 'full';
public function setMethod($method) {
$this->method = $method;
return $this;
}
public function setIsStandalone($is_standalone) {
$this->isStandalone = $is_standalone;
return $this;
}
public function setErrors(array $errors) {
$this->errors = $errors;
return $this;
}
public function getIsStandalone() {
return $this->isStandalone;
}
public function setSubmitURI($uri) {
$this->submitURI = $uri;
return $this;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function getTitle() {
return $this->title;
}
public function setShortTitle($short_title) {
$this->shortTitle = $short_title;
return $this;
}
public function getShortTitle() {
return $this->shortTitle;
}
public function setResizeY($resize_y) {
$this->resizeY = $resize_y;
return $this;
}
public function getResizeY() {
return $this->resizeY;
}
public function setResizeX($resize_x) {
$this->resizeX = $resize_x;
return $this;
}
public function getResizeX() {
return $this->resizeX;
}
public function addSubmitButton($text = null) {
if (!$text) {
$text = pht('Okay');
}
$this->submitButton = $text;
return $this;
}
public function addCancelButton($uri, $text = null) {
if (!$text) {
$text = pht('Cancel');
}
$this->cancelURI = $uri;
$this->cancelText = $text;
return $this;
}
public function addFooter($footer) {
$this->footers[] = $footer;
return $this;
}
public function addHiddenInput($key, $value) {
if (is_array($value)) {
foreach ($value as $hidden_key => $hidden_value) {
$this->hidden[] = array($key.'['.$hidden_key.']', $hidden_value);
}
} else {
$this->hidden[] = array($key, $value);
}
return $this;
}
public function setClass($class) {
$this->class = $class;
return $this;
}
public function setFlush($flush) {
$this->flush = $flush;
return $this;
}
public function setRenderDialogAsDiv() {
// TODO: This API is awkward.
$this->renderAsForm = false;
return $this;
}
public function setFormID($id) {
$this->formID = $id;
return $this;
}
public function setWidth($width) {
$this->width = $width;
return $this;
}
public function setObjectList(PHUIObjectItemListView $list) {
$this->objectList = true;
$box = id(new PHUIObjectBoxView())
->setObjectList($list);
return $this->appendChild($box);
}
+ public function appendRemarkup($remarkup) {
+ $viewer = $this->getViewer();
+ $view = new PHUIRemarkupView($viewer, $remarkup);
+
+ $view_tag = phutil_tag(
+ 'div',
+ array(
+ 'class' => 'aphront-dialog-view-paragraph',
+ ),
+ $view);
+
+ return $this->appendChild($view_tag);
+ }
+
public function appendParagraph($paragraph) {
return $this->appendParagraphTag($paragraph);
}
public function appendCommand($command) {
$command_tag = phutil_tag('tt', array(), $command);
return $this->appendParagraphTag(
$command_tag,
'aphront-dialog-view-command');
}
private function appendParagraphTag($content, $classes = null) {
if ($classes) {
$classes = (array)$classes;
} else {
$classes = array();
}
array_unshift($classes, 'aphront-dialog-view-paragraph');
$paragraph_tag = phutil_tag(
'p',
array(
'class' => implode(' ', $classes),
),
$content);
return $this->appendChild($paragraph_tag);
}
public function appendList(array $items) {
$listitems = array();
foreach ($items as $item) {
$listitems[] = phutil_tag(
'li',
array(
'class' => 'remarkup-list-item',
),
$item);
}
return $this->appendChild(
phutil_tag(
'ul',
array(
'class' => 'remarkup-list',
),
$listitems));
}
public function appendForm(AphrontFormView $form) {
return $this->appendChild($form->buildLayoutView());
}
public function setDisableWorkflowOnSubmit($disable_workflow_on_submit) {
$this->disableWorkflowOnSubmit = $disable_workflow_on_submit;
return $this;
}
public function getDisableWorkflowOnSubmit() {
return $this->disableWorkflowOnSubmit;
}
public function setDisableWorkflowOnCancel($disable_workflow_on_cancel) {
$this->disableWorkflowOnCancel = $disable_workflow_on_cancel;
return $this;
}
public function getDisableWorkflowOnCancel() {
return $this->disableWorkflowOnCancel;
}
public function setValidationException(
PhabricatorApplicationTransactionValidationException $ex = null) {
$this->validationException = $ex;
return $this;
}
public function render() {
require_celerity_resource('aphront-dialog-view-css');
$buttons = array();
if ($this->submitButton) {
$meta = array();
if ($this->disableWorkflowOnSubmit) {
$meta['disableWorkflow'] = true;
}
$buttons[] = javelin_tag(
'button',
array(
'name' => '__submit__',
'sigil' => '__default__',
'type' => 'submit',
'meta' => $meta,
),
$this->submitButton);
}
if ($this->cancelURI) {
$meta = array();
if ($this->disableWorkflowOnCancel) {
$meta['disableWorkflow'] = true;
}
$buttons[] = javelin_tag(
'a',
array(
'href' => $this->cancelURI,
'class' => 'button button-grey',
'name' => '__cancel__',
'sigil' => 'jx-workflow-button',
'meta' => $meta,
),
$this->cancelText);
}
if (!$this->hasViewer()) {
throw new Exception(
pht(
'You must call %s when rendering an %s.',
'setViewer()',
__CLASS__));
}
$classes = array();
$classes[] = 'aphront-dialog-view';
$classes[] = $this->class;
if ($this->flush) {
$classes[] = 'aphront-dialog-flush';
}
switch ($this->width) {
case self::WIDTH_FORM:
case self::WIDTH_FULL:
$classes[] = 'aphront-dialog-view-width-'.$this->width;
break;
case self::WIDTH_DEFAULT:
break;
default:
throw new Exception(
pht(
"Unknown dialog width '%s'!",
$this->width));
}
if ($this->isStandalone) {
$classes[] = 'aphront-dialog-view-standalone';
}
if ($this->objectList) {
$classes[] = 'aphront-dialog-object-list';
}
$attributes = array(
'class' => implode(' ', $classes),
'sigil' => 'jx-dialog',
'role' => 'dialog',
);
$form_attributes = array(
'action' => $this->submitURI,
'method' => $this->method,
'id' => $this->formID,
);
$hidden_inputs = array();
$hidden_inputs[] = phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => '__dialog__',
'value' => '1',
));
foreach ($this->hidden as $desc) {
list($key, $value) = $desc;
$hidden_inputs[] = javelin_tag(
'input',
array(
'type' => 'hidden',
'name' => $key,
'value' => $value,
'sigil' => 'aphront-dialog-application-input',
));
}
if (!$this->renderAsForm) {
$buttons = array(
phabricator_form(
$this->getViewer(),
$form_attributes,
array_merge($hidden_inputs, $buttons)),
);
}
$children = $this->renderChildren();
$errors = $this->errors;
$ex = $this->validationException;
$exception_errors = null;
if ($ex) {
foreach ($ex->getErrors() as $error) {
$errors[] = $error->getMessage();
}
}
if ($errors) {
$children = array(
id(new PHUIInfoView())->setErrors($errors),
$children,
);
}
$header = new PHUIHeaderView();
$header->setHeader($this->title);
$footer = null;
if ($this->footers) {
$footer = phutil_tag(
'div',
array(
'class' => 'aphront-dialog-foot',
),
$this->footers);
}
$resize = null;
if ($this->resizeX || $this->resizeY) {
$resize = javelin_tag(
'div',
array(
'class' => 'aphront-dialog-resize',
'sigil' => 'jx-dialog-resize',
'meta' => array(
'resizeX' => $this->resizeX,
'resizeY' => $this->resizeY,
),
));
}
$tail = null;
if ($buttons || $footer) {
$tail = phutil_tag(
'div',
array(
'class' => 'aphront-dialog-tail grouped',
),
array(
$buttons,
$footer,
$resize,
));
}
$content = array(
phutil_tag(
'div',
array(
'class' => 'aphront-dialog-head',
),
$header),
phutil_tag('div',
array(
'class' => 'aphront-dialog-body grouped',
),
$children),
$tail,
);
if ($this->renderAsForm) {
return phabricator_form(
$this->getViewer(),
$form_attributes + $attributes,
array($hidden_inputs, $content));
} else {
return javelin_tag(
'div',
$attributes,
$content);
}
}
/* -( AphrontResponseProducerInterface )----------------------------------- */
public function produceAphrontResponse() {
return id(new AphrontDialogResponse())
->setDialog($this);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 1, 4:05 PM (10 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
164437
Default Alt Text
(19 KB)

Event Timeline