mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 10:41:08 +01:00
Utilize hsprintf() in OAuth
Test Plan: /oauth/facebook/login/?error=<a> Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1577
This commit is contained in:
parent
7a0337054b
commit
be424bf381
2 changed files with 62 additions and 51 deletions
|
@ -41,7 +41,7 @@ class PhabricatorOAuthLoginController extends PhabricatorAuthController {
|
|||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
$provider_name = phutil_escape_html($provider->getProviderName());
|
||||
$provider_name = $provider->getProviderName();
|
||||
$provider_key = $provider->getProviderKey();
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
@ -79,11 +79,13 @@ class PhabricatorOAuthLoginController extends PhabricatorAuthController {
|
|||
$dialog->setUser($current_user);
|
||||
$dialog->setTitle('Already Linked to Another Account');
|
||||
$dialog->appendChild(
|
||||
'<p>The '.$provider_name.' account you just authorized '.
|
||||
'is already linked to another Phabricator account. Before you can '.
|
||||
'associate your '.$provider_name.' account with this Phabriactor '.
|
||||
'account, you must unlink it from the Phabricator account it is '.
|
||||
'currently linked to.</p>');
|
||||
hsprintf(
|
||||
'<p>The %s account you just authorized is already linked to '.
|
||||
'another Phabricator account. Before you can associate your %s '.
|
||||
'account with this Phabriactor account, you must unlink it from '.
|
||||
'the Phabricator account it is currently linked to.</p>',
|
||||
$provider_name,
|
||||
$provider_name));
|
||||
$dialog->addCancelButton('/settings/page/'.$provider_key.'/');
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
|
@ -103,9 +105,12 @@ class PhabricatorOAuthLoginController extends PhabricatorAuthController {
|
|||
$dialog->setUser($current_user);
|
||||
$dialog->setTitle('Already Linked to an Account From This Provider');
|
||||
$dialog->appendChild(
|
||||
'<p>The account you are logged in with is already linked to a '.
|
||||
$provider_name.' account. Before you can link it to a different '.
|
||||
$provider_name.' account, you must unlink the old account.</p>');
|
||||
hsprintf(
|
||||
'<p>The account you are logged in with is already linked to a %s '.
|
||||
'account. Before you can link it to a different %s account, you '.
|
||||
'must unlink the old account.</p>',
|
||||
$provider_name,
|
||||
$provider_name));
|
||||
$dialog->addCancelButton('/settings/page/'.$provider_key.'/');
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
@ -113,10 +118,11 @@ class PhabricatorOAuthLoginController extends PhabricatorAuthController {
|
|||
if (!$request->isDialogFormPost()) {
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setUser($current_user);
|
||||
$dialog->setTitle('Link '.$provider->getProviderName().' Account');
|
||||
$dialog->setTitle('Link '.$provider_name.' Account');
|
||||
$dialog->appendChild(
|
||||
'<p>Link your '.$provider_name.' account to your Phabricator '.
|
||||
'account?</p>');
|
||||
hsprintf(
|
||||
'<p>Link your %s account to your Phabricator account?</p>',
|
||||
$provider_name));
|
||||
$dialog->addHiddenInput('token', $provider->getAccessToken());
|
||||
$dialog->addHiddenInput('expires', $oauth_info->getTokenExpires());
|
||||
$dialog->addHiddenInput('state', $this->oauthState);
|
||||
|
@ -171,10 +177,12 @@ class PhabricatorOAuthLoginController extends PhabricatorAuthController {
|
|||
$dialog->setUser($current_user);
|
||||
$dialog->setTitle('Already Linked to Another Account');
|
||||
$dialog->appendChild(
|
||||
'<p>The '.$provider_name.' account you just authorized has an '.
|
||||
'email address which is already in use by another Phabricator '.
|
||||
'account. To link the accounts, log in to your Phabricator '.
|
||||
'account and then go to Settings.</p>');
|
||||
hsprintf(
|
||||
'<p>The %s account you just authorized has an email address which '.
|
||||
'is already in use by another Phabricator account. To link the '.
|
||||
'accounts, log in to your Phabricator account and then go to '.
|
||||
'Settings.</p>',
|
||||
$provider_name));
|
||||
$dialog->addCancelButton('/login/');
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
|
@ -184,13 +192,14 @@ class PhabricatorOAuthLoginController extends PhabricatorAuthController {
|
|||
if (!$provider->isProviderRegistrationEnabled()) {
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setUser($current_user);
|
||||
$dialog->setTitle('No Account Registration With '.
|
||||
$provider->getProviderName());
|
||||
$dialog->setTitle('No Account Registration With '.$provider_name);
|
||||
$dialog->appendChild(
|
||||
'<p>You can not register a new account using '.$provider_name.'; '.
|
||||
'you can only use your '.$provider_name.' account to log into an '.
|
||||
'existing Phabricator account which you have registered through '.
|
||||
'other means.</p>');
|
||||
hsprintf(
|
||||
'<p>You can not register a new account using %s; you can only use '.
|
||||
'your %s account to log into an existing Phabricator account which '.
|
||||
'you have registered through other means.</p>',
|
||||
$provider_name,
|
||||
$provider_name));
|
||||
$dialog->addCancelButton('/login/');
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
|
|
|
@ -34,49 +34,51 @@ class PhabricatorOAuthFailureView extends AphrontView {
|
|||
public function render() {
|
||||
$request = $this->request;
|
||||
$provider = $this->provider;
|
||||
$provider_name = phutil_escape_html($provider->getProviderName());
|
||||
$provider_name = $provider->getProviderName();
|
||||
|
||||
$diagnose = null;
|
||||
|
||||
$view = new AphrontRequestFailureView();
|
||||
$view->setHeader($provider->getProviderName().' Auth Failed');
|
||||
$view->setHeader($provider_name.' Auth Failed');
|
||||
if ($this->request) {
|
||||
$view->appendChild(
|
||||
'<p>'.
|
||||
'<strong>Description:</strong> '.
|
||||
phutil_escape_html($request->getStr('error_description')).
|
||||
'</p>');
|
||||
hsprintf(
|
||||
'<p><strong>Description:</strong> %s</p>',
|
||||
$request->getStr('error_description')));
|
||||
$view->appendChild(
|
||||
'<p>'.
|
||||
'<strong>Error:</strong> '.
|
||||
phutil_escape_html($request->getStr('error')).
|
||||
'</p>');
|
||||
hsprintf(
|
||||
'<p><strong>Error:</strong> %s</p>',
|
||||
$request->getStr('error')));
|
||||
$view->appendChild(
|
||||
'<p>'.
|
||||
'<strong>Error Reason:</strong> '.
|
||||
phutil_escape_html($request->getStr('error_reason')).
|
||||
'</p>');
|
||||
hsprintf(
|
||||
'<p><strong>Error Reason:</strong> %s</p>',
|
||||
$request->getStr('error_reason')));
|
||||
} else {
|
||||
// TODO: We can probably refine this.
|
||||
$view->appendChild(
|
||||
'<p>Unable to authenticate with '.$provider_name.'. '.
|
||||
hsprintf(
|
||||
'<p>Unable to authenticate with %s. '.
|
||||
'There are several reasons this might happen:</p>'.
|
||||
'<ul>'.
|
||||
'<li>Phabricator may be configured with the wrong Application '.
|
||||
'Secret; or</li>'.
|
||||
'<li>the '.$provider_name.' OAuth access token may have expired; '.
|
||||
'<li>the %s OAuth access token may have expired; or</li>'.
|
||||
'<li>%s may have revoked authorization for the Application; '.
|
||||
'or</li>'.
|
||||
'<li>'.$provider_name.' may have revoked authorization for the '.
|
||||
'Application; or</li>'.
|
||||
'<li>'.$provider_name.' may be having technical problems.</li>'.
|
||||
'<li>%s may be having technical problems.</li>'.
|
||||
'</ul>'.
|
||||
'<p>You can try again, or login using another method.</p>');
|
||||
'<p>You can try again, or login using another method.</p>',
|
||||
$provider_name,
|
||||
$provider_name,
|
||||
$provider_name,
|
||||
$provider_name));
|
||||
|
||||
$provider_key = $provider->getProviderKey();
|
||||
$diagnose =
|
||||
$diagnose = hsprintf(
|
||||
'<a href="/oauth/'.$provider_key.'/diagnose/" class="button green">'.
|
||||
'Diagnose '.$provider_name.' OAuth Problems'.
|
||||
'</a>';
|
||||
'Diagnose %s OAuth Problems'.
|
||||
'</a>',
|
||||
$provider_name);
|
||||
}
|
||||
|
||||
$view->appendChild(
|
||||
|
|
Loading…
Reference in a new issue