Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14085924
D20106.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D20106.diff
View Options
diff --git a/src/applications/auth/controller/PhabricatorAuthUnlinkController.php b/src/applications/auth/controller/PhabricatorAuthUnlinkController.php
--- a/src/applications/auth/controller/PhabricatorAuthUnlinkController.php
+++ b/src/applications/auth/controller/PhabricatorAuthUnlinkController.php
@@ -32,8 +32,15 @@
}
}
- // Check that this account isn't the last account which can be used to
- // login. We prevent you from removing the last account.
+ $confirmations = $request->getStrList('confirmations');
+ $confirmations = array_fuse($confirmations);
+
+ if (!$request->isFormPost() || !isset($confirmations['unlink'])) {
+ return $this->renderConfirmDialog($confirmations);
+ }
+
+ // Check that this account isn't the only account which can be used to
+ // login. We warn you when you remove your only login account.
if ($account->isUsableForLogin()) {
$other_accounts = id(new PhabricatorExternalAccount())->loadAllWhere(
'userPHID = %s',
@@ -47,22 +54,20 @@
}
if ($valid_accounts < 2) {
- return $this->renderLastUsableAccountErrorDialog();
+ if (!isset($confirmations['only'])) {
+ return $this->renderOnlyUsableAccountConfirmDialog($confirmations);
+ }
}
}
- if ($request->isDialogFormPost()) {
- $account->delete();
-
- id(new PhabricatorAuthSessionEngine())->terminateLoginSessions(
- $viewer,
- new PhutilOpaqueEnvelope(
- $request->getCookie(PhabricatorCookies::COOKIE_SESSION)));
+ $account->delete();
- return id(new AphrontRedirectResponse())->setURI($this->getDoneURI());
- }
+ id(new PhabricatorAuthSessionEngine())->terminateLoginSessions(
+ $viewer,
+ new PhutilOpaqueEnvelope(
+ $request->getCookie(PhabricatorCookies::COOKIE_SESSION)));
- return $this->renderConfirmDialog();
+ return id(new AphrontRedirectResponse())->setURI($this->getDoneURI());
}
private function getDoneURI() {
@@ -97,22 +102,27 @@
return id(new AphrontDialogResponse())->setDialog($dialog);
}
- private function renderLastUsableAccountErrorDialog() {
- $dialog = id(new AphrontDialogView())
- ->setUser($this->getRequest()->getUser())
- ->setTitle(pht('Last Valid Account'))
- ->appendChild(
- pht(
- 'You can not unlink this account because you have no other '.
- 'valid login accounts. If you removed it, you would be unable '.
- 'to log in. Add another authentication method before removing '.
- 'this one.'))
- ->addCancelButton($this->getDoneURI());
+ private function renderOnlyUsableAccountConfirmDialog(array $confirmations) {
+ $confirmations[] = 'only';
- return id(new AphrontDialogResponse())->setDialog($dialog);
+ return $this->newDialog()
+ ->setTitle(pht('Unlink Your Only Login Account?'))
+ ->addHiddenInput('confirmations', implode(',', $confirmations))
+ ->appendParagraph(
+ pht(
+ 'This is the only external login account linked to your Phabicator '.
+ 'account. If you remove it, you may no longer be able to log in.'))
+ ->appendParagraph(
+ pht(
+ 'If you lose access to your account, you can recover access by '.
+ 'sending yourself an email login link from the login screen.'))
+ ->addCancelButton($this->getDoneURI())
+ ->addSubmitButton(pht('Unlink External Account'));
}
- private function renderConfirmDialog() {
+ private function renderConfirmDialog(array $confirmations) {
+ $confirmations[] = 'unlink';
+
$provider_key = $this->providerKey;
$provider = PhabricatorAuthProvider::getEnabledProviderByKey($provider_key);
@@ -129,9 +139,9 @@
'to Phabricator.');
}
- $dialog = id(new AphrontDialogView())
- ->setUser($this->getRequest()->getUser())
+ return $this->newDialog()
->setTitle($title)
+ ->addHiddenInput('confirmations', implode(',', $confirmations))
->appendParagraph($body)
->appendParagraph(
pht(
@@ -139,8 +149,6 @@
'other active login sessions.'))
->addSubmitButton(pht('Unlink Account'))
->addCancelButton($this->getDoneURI());
-
- return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
diff --git a/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php b/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php
--- a/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php
+++ b/src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php
@@ -41,13 +41,6 @@
->setUser($viewer)
->setNoDataString(pht('You have no linked accounts.'));
- $login_accounts = 0;
- foreach ($accounts as $account) {
- if ($account->isUsableForLogin()) {
- $login_accounts++;
- }
- }
-
foreach ($accounts as $account) {
$item = new PHUIObjectItemView();
@@ -72,8 +65,6 @@
'account provider).'));
}
- $can_unlink = $can_unlink && (!$can_login || ($login_accounts > 1));
-
$can_refresh = $provider && $provider->shouldAllowAccountRefresh();
if ($can_refresh) {
$item->addAction(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 1:28 PM (19 h, 29 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6782888
Default Alt Text
D20106.diff (5 KB)
Attached To
Mode
D20106: Allow users to unlink their last external account with a warning, instead of preventing the action
Attached
Detach File
Event Timeline
Log In to Comment