Version 4.7.6
This commit is contained in:
1 parent
8ba7d43898
commit
7b7404e741
1085 files changed
+30590
-7837
No files matched your search
@@ -828,23 +828,23 @@ abstract class _Handler extends \IPS\Node\Model
|
||||
{
|
||||
$form->addHeader('login_method_basic_settings');
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'login_method_name', NULL, TRUE, array( 'app' => 'core', 'key' => ( $this->id ? 'login_method_' . $this->id : NULL ) ) ) );
|
||||
if ( !( $this instanceof \IPS\Login\Handler\Standard ) )
|
||||
{
|
||||
if ( !( $this instanceof \IPS\Login\Handler\Standard ) ) {
|
||||
$self = $this;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'login_acp', $this->id ? $this->acp : static::$enableAcpLoginByDefault, FALSE, array(), function( $val ) use ( $self )
|
||||
{
|
||||
if ( !$val )
|
||||
{
|
||||
foreach ( \IPS\Login::methods() as $method )
|
||||
{
|
||||
if ( $method != $self and $method->canProcess( \IPS\Member::loggedIn() ) and $method->acp )
|
||||
{
|
||||
$form->add(new \IPS\Helpers\Form\YesNo('login_acp', $this->id ? $this->acp : static::$enableAcpLoginByDefault, FALSE, array(), function ($val) use ($self) {
|
||||
if (!$val) {
|
||||
foreach (\IPS\Login::methods() as $method) {
|
||||
if ($method != $self and $method->canProcess(\IPS\Member::loggedIn()) and $method->acp) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new \DomainException( 'login_handler_cannot_disable_acp' );
|
||||
throw new \DomainException('login_handler_cannot_disable_acp');
|
||||
}
|
||||
} ) );
|
||||
}));
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'login_front', $this->id ? $this->front : static::$enableAcpLoginByDefault, FALSE, array() ) );
|
||||
|
||||
if ( !( $this instanceof \IPS\Login\Handler\Standard ) ) {
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'login_register', $this->id ? $this->register : TRUE, FALSE, array(
|
||||
'options' => array(
|
||||
1 => 'login_register_enabled',
|
||||
@@ -856,6 +856,8 @@ abstract class _Handler extends \IPS\Node\Model
|
||||
) ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'login_front', $this->id ? $this->front : static::$enableAcpLoginByDefault, FALSE, array() ) );
|
||||
|
||||
foreach ( $this->acpForm() as $key => $field )
|
||||
{
|
||||
if ( \is_string( $field ) )
|
||||
|
||||
@@ -47,6 +47,7 @@ abstract class _OAuth1 extends \IPS\Login\Handler
|
||||
'options' => array(
|
||||
'always' => 'login_handler_show_in_ucp_always',
|
||||
'loggedin' => 'login_handler_show_in_ucp_loggedin',
|
||||
'disabled' => 'login_handler_show_in_ucp_disabled'
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
@@ -402,7 +402,13 @@ class _Twitter extends \IPS\Login\Handler\OAuth1
|
||||
}
|
||||
return $this->_cachedUserData[ $accessToken ];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief The length of the shortened URLs returned by Twitter's text parser https://developer.twitter.com/en/docs/counting-characters#:~:text=The%20current%20length%20of%20a,count%20towards%20the%20character%20limit.
|
||||
*/
|
||||
protected static $defaultShortenedUrlLength = 23;
|
||||
|
||||
/**
|
||||
* Post something to Twitter
|
||||
*
|
||||
@@ -419,15 +425,33 @@ class _Twitter extends \IPS\Login\Handler\OAuth1
|
||||
}
|
||||
|
||||
$data = array( 'status' => $content );
|
||||
|
||||
|
||||
/* If we have a url, add it to the end prepended by a space */
|
||||
if ( $url !== NULL )
|
||||
{
|
||||
/* Try to refresh if the stored response is more than a day old */
|
||||
if ( !isset( \IPS\Data\Store::i()->twitter_config ) or \IPS\Data\Store::i()->twitter_config['time'] > time() - 86400 )
|
||||
{
|
||||
$response = $this->_sendRequest( 'get', \IPS\Http\Url::external('https://api.twitter.com/1.1/help/configuration.json'), array(), $link['token_access_token'], $link['token_secret'] )->decodeJson();
|
||||
\IPS\Data\Store::i()->twitter_config = array_merge( $response, array( 'time' => time() ) );
|
||||
try
|
||||
{
|
||||
$response = $this->_sendRequest( 'get', \IPS\Http\Url::external('https://api.twitter.com/1.1/help/configuration.json'), array(), $link['token_access_token'], $link['token_secret'] );
|
||||
if ( ( $response->httpResponseCode === 200 ) AND ( $payload = $response->decodeJson() ) AND \is_array( $payload ) )
|
||||
{
|
||||
\IPS\Data\Store::i()->twitter_config = array_merge( $payload, array( 'time' => time() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \UnexpectedValueException();
|
||||
}
|
||||
}
|
||||
catch ( \Exception|\UnexpectedValueException $e )
|
||||
{
|
||||
/* We should be fine hard coding to 23 if the deprecated configuration endpoint is no longer online https://developer.twitter.com/en/docs/counting-characters#:~:text=The%20current%20length%20of%20a,count%20towards%20the%20character%20limit. */
|
||||
\IPS\Data\Store::i()->twitter_config['short_url_length'] = static::$defaultShortenedUrlLength;
|
||||
}
|
||||
}
|
||||
$maxUrlLen = \IPS\Data\Store::i()->twitter_config['short_url_length'];
|
||||
|
||||
$maxUrlLen = \IPS\Data\Store::i()->twitter_config['short_url_length'] ?? static::$defaultShortenedUrlLength;
|
||||
$data['status'] = mb_substr( $data['status'], 0, ( 140 - ( $maxUrlLen + 1 ) ) ) . ' ' . $url;
|
||||
}
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ class _Custom extends \IPS\Login\Handler\OAuth2
|
||||
}
|
||||
|
||||
/* Check for any errors */
|
||||
if ( static::getValueFromArray( $response, $this->settings['uid_field'] ) === NULL )
|
||||
if ( $response === NULL OR static::getValueFromArray( $response, $this->settings['uid_field'] ) === NULL )
|
||||
{
|
||||
\IPS\Log::log( print_r( $response, TRUE ), 'oauth_custom' );
|
||||
throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR );
|
||||
|
||||
@@ -374,7 +374,16 @@ class _Google extends \IPS\Login\Handler\OAuth2
|
||||
|
||||
if ( isset( $response['error'] ) )
|
||||
{
|
||||
throw new \IPS\Login\Exception( $response['error']['errors'][0]['message'], \IPS\Login\Exception::INTERNAL_ERROR );
|
||||
if ( isset( $response['error_description'] ) )
|
||||
{
|
||||
throw new \IPS\Login\Exception( $response['error_description'], \IPS\Login\Exception::INTERNAL_ERROR );
|
||||
}
|
||||
// Keeping this for backwards compatibility..
|
||||
else if( isset( $response['error']['errors'][0]['message'] ) )
|
||||
{
|
||||
throw new \IPS\Login\Exception( $response['error']['errors'][0]['message'], \IPS\Login\Exception::INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->_cachedUserData[ $accessToken ] = $response;
|
||||
|
||||
@@ -73,6 +73,7 @@ abstract class _OAuth2 extends \IPS\Login\Handler
|
||||
'options' => array(
|
||||
'always' => 'login_handler_show_in_ucp_always',
|
||||
'loggedin' => 'login_handler_show_in_ucp_loggedin',
|
||||
'disabled' => 'login_handler_show_in_ucp_disabled'
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
Reference in new issue
Block a user