2011-02-21 07:47:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-02-03 02:06:02 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-02-21 07:47:56 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-03-13 19:18:11 +01:00
|
|
|
final class PhabricatorOAuthFailureView extends AphrontView {
|
2011-02-21 07:47:56 +01:00
|
|
|
|
|
|
|
private $request;
|
|
|
|
private $provider;
|
|
|
|
|
|
|
|
public function setRequest(AphrontRequest $request) {
|
|
|
|
$this->request = $request;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOAuthProvider($provider) {
|
|
|
|
$this->provider = $provider;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$request = $this->request;
|
|
|
|
$provider = $this->provider;
|
2012-02-05 05:48:19 +01:00
|
|
|
$provider_name = $provider->getProviderName();
|
2011-02-21 07:47:56 +01:00
|
|
|
|
|
|
|
$diagnose = null;
|
|
|
|
|
|
|
|
$view = new AphrontRequestFailureView();
|
2012-02-05 05:48:19 +01:00
|
|
|
$view->setHeader($provider_name.' Auth Failed');
|
2011-02-21 07:47:56 +01:00
|
|
|
if ($this->request) {
|
|
|
|
$view->appendChild(
|
2012-02-05 05:48:19 +01:00
|
|
|
hsprintf(
|
|
|
|
'<p><strong>Description:</strong> %s</p>',
|
|
|
|
$request->getStr('error_description')));
|
2011-02-21 07:47:56 +01:00
|
|
|
$view->appendChild(
|
2012-02-05 05:48:19 +01:00
|
|
|
hsprintf(
|
|
|
|
'<p><strong>Error:</strong> %s</p>',
|
|
|
|
$request->getStr('error')));
|
2011-02-21 07:47:56 +01:00
|
|
|
$view->appendChild(
|
2012-02-05 05:48:19 +01:00
|
|
|
hsprintf(
|
|
|
|
'<p><strong>Error Reason:</strong> %s</p>',
|
|
|
|
$request->getStr('error_reason')));
|
2011-02-21 07:47:56 +01:00
|
|
|
} else {
|
|
|
|
// TODO: We can probably refine this.
|
|
|
|
$view->appendChild(
|
2012-02-05 05:48:19 +01:00
|
|
|
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 %s OAuth access token may have expired; or</li>'.
|
|
|
|
'<li>%s may have revoked authorization for the Application; '.
|
|
|
|
'or</li>'.
|
|
|
|
'<li>%s may be having technical problems.</li>'.
|
|
|
|
'</ul>'.
|
|
|
|
'<p>You can try again, or login using another method.</p>',
|
|
|
|
$provider_name,
|
|
|
|
$provider_name,
|
|
|
|
$provider_name,
|
|
|
|
$provider_name));
|
2011-02-21 07:47:56 +01:00
|
|
|
|
|
|
|
$provider_key = $provider->getProviderKey();
|
2012-02-05 05:48:19 +01:00
|
|
|
$diagnose = hsprintf(
|
2011-02-21 07:47:56 +01:00
|
|
|
'<a href="/oauth/'.$provider_key.'/diagnose/" class="button green">'.
|
2012-02-05 05:48:19 +01:00
|
|
|
'Diagnose %s OAuth Problems'.
|
|
|
|
'</a>',
|
|
|
|
$provider_name);
|
2011-02-21 07:47:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$view->appendChild(
|
|
|
|
'<div class="aphront-failure-continue">'.
|
|
|
|
$diagnose.
|
|
|
|
'<a href="/login/" class="button">Continue</a>'.
|
|
|
|
'</div>');
|
|
|
|
|
|
|
|
return $view->render();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|