When users follow an email login link but an install does not use passwords, try to get them to link an account
Summary:
Ref T13249. See PHI774. When users follow an email login link ("Forgot password?", "Send Welcome Email", "Send a login link to your email address.", `bin/auth recover`), we send them to a password reset flow if an install uses passwords.
If an install does not use passwords, we previously dumped them unceremoniously into the {nav Settings > External Accounts} UI with no real guidance about what they were supposed to do. Since D20094 we do a slightly better job here in some cases. Continue improving this workflow.
This adds a page like "Reset Password" for "Hey, You Should Probably Link An Account, Here's Some Options".
Overall, this stuff is still pretty rough in a couple of areas that I imagine addressing in the future:
- When you finish linking, we still dump you back in Settings. At least we got you to link things. But better would be to return you here and say "great job, you're a pro".
- This UI can become a weird pile of buttons in certain configs and generally looks a little unintentional. This problem is shared among all the "linkable" providers, and the non-login link flow is also weird.
So: step forward, but more work to be done.
Test Plan: {F6211115}
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13249
Differential Revision: https://secure.phabricator.com/D20170
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorAuthSetExternalController
|
||||
extends PhabricatorAuthController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$configs = id(new PhabricatorAuthProviderConfigQuery())
|
||||
->setViewer($viewer)
|
||||
->withIsEnabled(true)
|
||||
->execute();
|
||||
|
||||
$linkable = array();
|
||||
foreach ($configs as $config) {
|
||||
if (!$config->getShouldAllowLink()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For now, only buttons get to appear here: for example, we can't
|
||||
// reasonably embed an entire LDAP form into this UI.
|
||||
$provider = $config->getProvider();
|
||||
if (!$provider->isLoginFormAButton()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$linkable[] = $config;
|
||||
}
|
||||
|
||||
if (!$linkable) {
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('No Linkable External Providers'))
|
||||
->appendParagraph(
|
||||
pht(
|
||||
'Currently, there are no configured external auth providers '.
|
||||
'which you can link your account to.'))
|
||||
->addCancelButton('/');
|
||||
}
|
||||
|
||||
$text = PhabricatorAuthMessage::loadMessageText(
|
||||
$viewer,
|
||||
PhabricatorAuthLinkMessageType::MESSAGEKEY);
|
||||
if (!strlen($text)) {
|
||||
$text = pht(
|
||||
'You can link your Phabricator account to an external account to '.
|
||||
'allow you to log in more easily in the future. To continue, choose '.
|
||||
'an account to link below. If you prefer not to link your account, '.
|
||||
'you can skip this step.');
|
||||
}
|
||||
|
||||
$remarkup_view = new PHUIRemarkupView($viewer, $text);
|
||||
$remarkup_view = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phui-object-box-instructions',
|
||||
),
|
||||
$remarkup_view);
|
||||
|
||||
PhabricatorCookies::setClientIDCookie($request);
|
||||
|
||||
$view = array();
|
||||
foreach ($configs as $config) {
|
||||
$provider = $config->getProvider();
|
||||
|
||||
$form = $provider->buildLinkForm($this);
|
||||
|
||||
if ($provider->isLoginFormAButton()) {
|
||||
require_celerity_resource('auth-css');
|
||||
$form = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-link-button pl',
|
||||
),
|
||||
$form);
|
||||
}
|
||||
|
||||
$view[] = $form;
|
||||
}
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setViewer($viewer)
|
||||
->appendControl(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton('/', pht('Skip This Step')));
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Link External Account'));
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setViewer($viewer)
|
||||
->setHeader($header)
|
||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||
->appendChild($remarkup_view)
|
||||
->appendChild($view)
|
||||
->appendChild($form);
|
||||
|
||||
$main_view = id(new PHUITwoColumnView())
|
||||
->setFooter($box);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs()
|
||||
->addTextCrumb(pht('Link External Account'))
|
||||
->setBorder(true);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle(pht('Link External Account'))
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild($main_view);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user