1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-03 03:11:01 +01:00

Improve more crumbs and cancel buttons for auth

Summary:
Ref T1536.

  - When linking accounts after initially failing, make the crumb say "Link Account" instead of "Login".
  - When on the LDAP failure form, show a "Cancel" button returning to start (if logging in) or settings (if linking accounts).
  - Allow providers to distinguish between "start", "login" and "link" rendering.

Test Plan: Linked and logged in with LDAP and other registration mechainsms.

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T1536

Differential Revision: https://secure.phabricator.com/D6214
This commit is contained in:
epriestley 2013-06-17 12:14:51 -07:00
parent 433c6550b2
commit fded36cc21
4 changed files with 40 additions and 19 deletions

View file

@ -178,10 +178,19 @@ final class PhabricatorAuthLoginController
$content) { $content) {
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView()) if ($this->getRequest()->getUser()->isLoggedIn()) {
->setName(pht('Login')) $crumbs->addCrumb(
->setHref($this->getApplicationURI('start/'))); id(new PhabricatorCrumbView())
->setName(pht('Link Account'))
->setHref($provider->getSettingsURI()));
} else {
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Login'))
->setHref($this->getApplicationURI('start/')));
}
$crumbs->addCrumb( $crumbs->addCrumb(
id(new PhabricatorCrumbView()) id(new PhabricatorCrumbView())
->setName($provider->getProviderName())); ->setName($provider->getProviderName()));

View file

@ -108,7 +108,7 @@ abstract class PhabricatorAuthProvider {
public function buildLoginForm( public function buildLoginForm(
PhabricatorAuthStartController $controller) { PhabricatorAuthStartController $controller) {
return $this->renderLoginForm($controller->getRequest(), $is_link = false); return $this->renderLoginForm($controller->getRequest(), $mode = 'start');
} }
abstract public function processLoginRequest( abstract public function processLoginRequest(
@ -116,12 +116,12 @@ abstract class PhabricatorAuthProvider {
public function buildLinkForm( public function buildLinkForm(
PhabricatorAuthLinkController $controller) { PhabricatorAuthLinkController $controller) {
return $this->renderLoginForm($controller->getRequest(), $is_link = true); return $this->renderLoginForm($controller->getRequest(), $mode = 'link');
} }
protected function renderLoginForm( protected function renderLoginForm(
AphrontRequest $request, AphrontRequest $request,
$is_link) { $mode) {
throw new Exception("Not implemented!"); throw new Exception("Not implemented!");
} }
@ -213,16 +213,22 @@ abstract class PhabricatorAuthProvider {
return $account; return $account;
} }
protected function getLoginURI() { public function getLoginURI() {
$app = PhabricatorApplication::getByClass('PhabricatorApplicationAuth'); $app = PhabricatorApplication::getByClass('PhabricatorApplicationAuth');
$uri = $app->getApplicationURI('/login/'.$this->getProviderKey().'/'); $uri = $app->getApplicationURI('/login/'.$this->getProviderKey().'/');
return PhabricatorEnv::getURI($uri); return PhabricatorEnv::getURI($uri);
} }
protected function getCancelLinkURI() { public function getSettingsURI() {
return '/settings/panel/external/'; return '/settings/panel/external/';
} }
public function getStartURI() {
$app = PhabricatorApplication::getByClass('PhabricatorApplicationAuth');
$uri = $app->getApplicationURI('/start/');
return $uri;
}
public function isDefaultRegistrationProvider() { public function isDefaultRegistrationProvider() {
return false; return false;
} }

View file

@ -63,22 +63,28 @@ final class PhabricatorAuthProviderLDAP
return true; return true;
} }
protected function renderLoginForm(AphrontRequest $request, $is_link) { protected function renderLoginForm(AphrontRequest $request, $mode) {
$viewer = $request->getUser(); $viewer = $request->getUser();
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setSubmitURI($this->getLoginURI()) ->setSubmitURI($this->getLoginURI())
->setUser($viewer); ->setUser($viewer);
if ($is_link) { if ($mode == 'link') {
$dialog->setTitle(pht('Link LDAP Account')); $dialog->setTitle(pht('Link LDAP Account'));
$dialog->addSubmitButton(pht('Link Accounts')); $dialog->addSubmitButton(pht('Link Accounts'));
} else if ($this->shouldAllowRegistration()) { $dialog->addCancelButton($this->getSettingsURI());
$dialog->setTitle(pht('Login or Register with LDAP'));
$dialog->addSubmitButton(pht('Login or Register'));
} else { } else {
$dialog->setTitle(pht('Login with LDAP')); if ($this->shouldAllowRegistration()) {
$dialog->addSubmitButton(pht('Login')); $dialog->setTitle(pht('Login or Register with LDAP'));
$dialog->addSubmitButton(pht('Login or Register'));
} else {
$dialog->setTitle(pht('Login with LDAP'));
$dialog->addSubmitButton(pht('Login'));
}
if ($mode == 'login') {
$dialog->addCancelButton($this->getStartURI());
}
} }
$v_user = $request->getStr('ldap_username'); $v_user = $request->getStr('ldap_username');
@ -137,7 +143,7 @@ final class PhabricatorAuthProviderLDAP
if (!strlen($username) || !$has_password) { if (!strlen($username) || !$has_password) {
$response = $controller->buildProviderPageResponse( $response = $controller->buildProviderPageResponse(
$this, $this,
$this->renderLoginForm($request)); $this->renderLoginForm($request, 'login'));
return array($account, $response); return array($account, $response);
} }

View file

@ -44,10 +44,10 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
return true; return true;
} }
protected function renderLoginForm(AphrontRequest $request, $is_link) { protected function renderLoginForm(AphrontRequest $request, $mode) {
$viewer = $request->getUser(); $viewer = $request->getUser();
if ($is_link) { if ($mode == 'link') {
$button_text = pht('Link External Account'); $button_text = pht('Link External Account');
} else if ($this->shouldAllowRegistration()) { } else if ($this->shouldAllowRegistration()) {
$button_text = pht('Login or Register'); $button_text = pht('Login or Register');