Simplify the code
This commit is contained in:
parent
1b6212f8a8
commit
0b9c934cad
1 changed files with 5 additions and 7 deletions
|
@ -23,7 +23,6 @@ namespace Friendica\Module\OAuth;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Post\Content;
|
|
||||||
use Friendica\Module\BaseApi;
|
use Friendica\Module\BaseApi;
|
||||||
use Friendica\Security\OAuth;
|
use Friendica\Security\OAuth;
|
||||||
|
|
||||||
|
@ -33,6 +32,8 @@ use Friendica\Security\OAuth;
|
||||||
*/
|
*/
|
||||||
class Authorize extends BaseApi
|
class Authorize extends BaseApi
|
||||||
{
|
{
|
||||||
|
private static $oauth_code = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters
|
* @param array $parameters
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
@ -93,18 +94,15 @@ class Authorize extends BaseApi
|
||||||
DI::app()->redirect($application['redirect_uri'] . (strpos($application['redirect_uri'], '?') ? '&' : '?') . http_build_query(['code' => $token['code'], 'state' => $request['state']]));
|
DI::app()->redirect($application['redirect_uri'] . (strpos($application['redirect_uri'], '?') ? '&' : '?') . http_build_query(['code' => $token['code'], 'state' => $request['state']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
DI::session()->set('oauth_token_code', $token['code']);
|
self::$oauth_code = $token['code'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function content(array $parameters = [])
|
public static function content(array $parameters = [])
|
||||||
{
|
{
|
||||||
$code = DI::session()->get('oauth_token_code');
|
if (empty(self::$oauth_code)) {
|
||||||
DI::session()->remove('oauth_token_code');
|
|
||||||
|
|
||||||
if (empty($code)) {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return DI::l10n()->t('Please copy the following authentication code into your application and close this window: %s', $code);
|
return DI::l10n()->t('Please copy the following authentication code into your application and close this window: %s', self::$oauth_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue