Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,41 +11,76 @@
|
||||
namespace IPS\core\modules\admin\settings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use IPS\Application;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Extensions\SSOAbstract;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Address;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Stack;
|
||||
use IPS\Helpers\Form\Tel;
|
||||
use IPS\Helpers\Form\Url as FormUrl;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Helpers\Wizard;
|
||||
use IPS\Http\Request\Exception;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Login as LoginClass;
|
||||
use IPS\Login\Handler;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use LogicException;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login Methods
|
||||
*/
|
||||
class _login extends \IPS\Node\Controller
|
||||
class login extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\Login\Handler';
|
||||
protected string $nodeClass = 'IPS\Login\Handler';
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'login_access' );
|
||||
return parent::execute();
|
||||
Dispatcher::i()->checkAcpPermission( 'login_access' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +88,7 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _getRootButtons()
|
||||
public function _getRootButtons(): array
|
||||
{
|
||||
$buttons = parent::_getRootButtons();
|
||||
|
||||
@@ -70,31 +105,31 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Work out tabs */
|
||||
$tabs = array();
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'login_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'login_manage' ) )
|
||||
{
|
||||
$tabs['handlers'] = 'login_handlers';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'login_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'login_settings' ) )
|
||||
{
|
||||
$tabs['settings'] = 'login_settings';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'registration_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'registration_settings' ) )
|
||||
{
|
||||
$tabs['registration'] = 'registration_settings';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'login_account_management' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'login_account_management' ) )
|
||||
{
|
||||
$tabs['accountsettings'] = 'account_management_settings';
|
||||
}
|
||||
|
||||
/* Get active tab */
|
||||
if ( isset( \IPS\Request::i()->tab ) and isset( $tabs[ \IPS\Request::i()->tab ] ) )
|
||||
if ( isset( Request::i()->tab ) and isset( $tabs[ Request::i()->tab ] ) )
|
||||
{
|
||||
$activeTab = \IPS\Request::i()->tab;
|
||||
$activeTab = Request::i()->tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -107,9 +142,9 @@ class _login extends \IPS\Node\Controller
|
||||
switch ( $activeTab )
|
||||
{
|
||||
case 'handlers':
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'login_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'login_manage' );
|
||||
parent::manage();
|
||||
$output = \IPS\Output::i()->output;
|
||||
$output = Output::i()->output;
|
||||
break;
|
||||
case 'settings':
|
||||
$output = $this->_settings();
|
||||
@@ -123,22 +158,22 @@ class _login extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_login');
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_settings_login');
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $output;
|
||||
Output::i()->output = $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'forcelogout' => array(
|
||||
'title' => 'force_all_logout',
|
||||
'icon' => 'lock',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=login&do=forceLogout' )->csrf(),
|
||||
'link' => Url::internal( 'app=core&module=settings&controller=login&do=forceLogout' )->csrf(),
|
||||
'data' => array( 'confirm' => '' ),
|
||||
),
|
||||
);
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $output, \IPS\Http\Url::internal( "app=core&module=settings&controller=login" ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $output, Url::internal( "app=core&module=settings&controller=login" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,23 +182,24 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
protected function form() : void
|
||||
{
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
return parent::form();
|
||||
parent::form();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard( array(
|
||||
Output::i()->output = (string) new Wizard( array(
|
||||
'login_handler' => function( $data )
|
||||
{
|
||||
$options = array();
|
||||
foreach ( \IPS\Login\Handler::handlerClasses() as $class )
|
||||
foreach ( Handler::handlerClasses() as $class )
|
||||
{
|
||||
/* @var Handler $class */
|
||||
if ( !$class::$allowMultiple )
|
||||
{
|
||||
foreach ( \IPS\Login\Handler::roots() as $handler )
|
||||
foreach ( Handler::roots() as $handler )
|
||||
{
|
||||
if ( $handler instanceof $class )
|
||||
{
|
||||
@@ -174,8 +210,8 @@ class _login extends \IPS\Node\Controller
|
||||
$options[ $class ] = $class::getTitle();
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'login_handler_1', 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'login_handler', TRUE, NULL, array( 'options' => $options ), function( $val )
|
||||
$form = new Form( 'login_handler_1', 'continue' );
|
||||
$form->add( new Radio( 'login_handler', TRUE, NULL, array( 'options' => $options ), function( $val )
|
||||
{
|
||||
$val::testCompatibility();
|
||||
} ) );
|
||||
@@ -195,21 +231,21 @@ class _login extends \IPS\Node\Controller
|
||||
try
|
||||
{
|
||||
$node->settings = array();
|
||||
$node->order = \IPS\Db::i()->select( 'MAX(login_order)', $node::$databaseTable )->first() + 1;
|
||||
$node->order = Db::i()->select( 'MAX(login_order)', $node::$databaseTable )->first() + 1;
|
||||
$node->saveForm( $node->formatFormValues( $values ) );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__node_created', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
Session::i()->log( 'acplog__node_created', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=settings&controller=login') );
|
||||
Output::i()->redirect( Url::internal('app=core&module=settings&controller=login') );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
catch ( LogicException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
), \IPS\Http\Url::internal('app=core&module=settings&controller=login&do=form') );
|
||||
), Url::internal('app=core&module=settings&controller=login&do=form') );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,13 +255,13 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function enableToggle()
|
||||
protected function enableToggle() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$loginMethod = \IPS\Login\Handler::load( \IPS\Request::i()->id );
|
||||
$loginMethod = Handler::load( Request::i()->id );
|
||||
|
||||
if ( \IPS\Request::i()->status )
|
||||
if ( Request::i()->status )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -233,7 +269,7 @@ class _login extends \IPS\Node\Controller
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=settings&controller=login&do=form&id={$loginMethod->id}" ) );
|
||||
Output::i()->redirect( Url::internal( "app=core&module=settings&controller=login&do=form&id={$loginMethod->id}" ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -242,11 +278,11 @@ class _login extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
/* Clear caches */
|
||||
unset( \IPS\Data\Store::i()->loginMethods, \IPS\Data\Store::i()->essentialCookieNames );
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
unset( Store::i()->loginMethods, Store::i()->essentialCookieNames );
|
||||
Cache::i()->clearAll();
|
||||
|
||||
/* Toggle */
|
||||
return parent::enableToggle();
|
||||
parent::enableToggle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,36 +290,36 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
protected function delete() : void
|
||||
{
|
||||
/* Check it's okay */
|
||||
$loginMethod = \IPS\Login\Handler::load( \IPS\Request::i()->id );
|
||||
$loginMethod = Handler::load( Request::i()->id );
|
||||
$this->_disableCheck( $loginMethod );
|
||||
|
||||
/* Do it */
|
||||
parent::delete();
|
||||
|
||||
/* Clear caches */
|
||||
unset( \IPS\Data\Store::i()->loginMethods );
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
unset( Store::i()->loginMethods, Store::i()->essentialCookieNames );
|
||||
Cache::i()->clearAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* If a particular method is disabled/deleted - will we still be able to log in?
|
||||
*
|
||||
* @param \IPS\Login\Handler $methodToRemove Handler to be disabled/deleted
|
||||
* @return void
|
||||
* @param Handler $methodToRemove Handler to be disabled/deleted
|
||||
* @return bool
|
||||
*/
|
||||
protected function _disableCheck( \IPS\Login\Handler $methodToRemove )
|
||||
protected function _disableCheck( Handler $methodToRemove ) : bool
|
||||
{
|
||||
foreach ( \IPS\Login::methods() as $method )
|
||||
foreach ( LoginClass::methods() as $method )
|
||||
{
|
||||
if ( $method != $methodToRemove and $method->canProcess( \IPS\Member::loggedIn() ) and $method->acp )
|
||||
if ( $method != $methodToRemove and $method->canProcess( Member::loggedIn() ) and $method->acp )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
\IPS\Output::i()->error( 'login_handler_cannot_disable', '1C166/5', 403, '' );
|
||||
Output::i()->error( 'login_handler_cannot_disable', '1C166/5', 403, '' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,50 +327,47 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _settings()
|
||||
protected function _settings() : string
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'login_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'login_settings' );
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form = new Form();
|
||||
$form->addHeader( 'ipb_bruteforce_attempts_title' );
|
||||
$form->addMessage( 'ipb_bruteforce_attempts_block_desc', 'ipsMessage ipsMessage_info' );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'ipb_bruteforce_attempts', \IPS\Settings::i()->ipb_bruteforce_attempts, FALSE, array( 'min' => 0, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('failed_logins'), 'ipb_bruteforce_attempts' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'ipb_bruteforce_period', \IPS\Settings::i()->ipb_bruteforce_period, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::MINUTES, 'min' => 0, 'max' => 10000, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'ipb_bruteforce_period' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_bruteforce_unlock', \IPS\Settings::i()->ipb_bruteforce_unlock, FALSE, array(), NULL, NULL, NULL, 'ipb_bruteforce_unlock' ) );
|
||||
$form->addHtml( Theme::i()->getTemplate( 'forms' )->blurb( 'ipb_bruteforce_attempts_block_desc', true, true ) );
|
||||
$form->add( new Number( 'ipb_bruteforce_attempts', Settings::i()->ipb_bruteforce_attempts, FALSE, array( 'min' => 0, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), Member::loggedIn()->language()->addToStack('failed_logins'), 'ipb_bruteforce_attempts' ) );
|
||||
$form->add( new Interval( 'ipb_bruteforce_period', Settings::i()->ipb_bruteforce_period, FALSE, array( 'valueAs' => Interval::MINUTES, 'min' => 0, 'max' => 10000, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'ipb_bruteforce_period' ) );
|
||||
$form->add( new YesNo( 'ipb_bruteforce_unlock', Settings::i()->ipb_bruteforce_unlock, FALSE, array(), NULL, NULL, NULL, 'ipb_bruteforce_unlock' ) );
|
||||
$form->addHeader( 'bruteforce_global_attempts_title' );
|
||||
$form->addMessage( 'bruteforce_global_attempts_block_desc', 'ipsMessage ipsMessage_info' );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'bruteforce_global_attempts', \IPS\Settings::i()->bruteforce_global_attempts, FALSE, array( 'min' => 5 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('failed_logins'), 'bruteforce_global_attempts' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'bruteforce_global_period', \IPS\Settings::i()->bruteforce_global_period, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::MINUTES, 'min' => 0, 'max' => 10000 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'bruteforce_global_period' ) );
|
||||
$form->addHtml( Theme::i()->getTemplate( 'forms' )->blurb( 'bruteforce_global_attempts_block_desc', true, true ) );
|
||||
$form->add( new Number( 'bruteforce_global_attempts', Settings::i()->bruteforce_global_attempts, FALSE, array( 'min' => 5 ), NULL, Member::loggedIn()->language()->addToStack('after'), Member::loggedIn()->language()->addToStack('failed_logins'), 'bruteforce_global_attempts' ) );
|
||||
$form->add( new Interval( 'bruteforce_global_period', Settings::i()->bruteforce_global_period, FALSE, array( 'valueAs' => Interval::MINUTES, 'min' => 0, 'max' => 10000 ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'bruteforce_global_period' ) );
|
||||
|
||||
$form->addHeader( 'login_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'new_device_email', \IPS\Settings::i()->new_device_email, FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'login_after_inactivity_notification', \IPS\Settings::i()->login_after_inactivity_notification, FALSE ) );
|
||||
$form->add( new YesNo( 'new_device_email', Settings::i()->new_device_email, FALSE ) );
|
||||
|
||||
/* Save */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* unlock all locked members if we have disabled the locking */
|
||||
if ( \IPS\Settings::i()->ipb_bruteforce_attempts > 0 AND $values['ipb_bruteforce_attempts'] == 0 )
|
||||
if ( Settings::i()->ipb_bruteforce_attempts > 0 AND $values['ipb_bruteforce_attempts'] == 0 )
|
||||
{
|
||||
\IPS\Member::updateAllMembers( array( 'failed_login_count' => 0 ) );
|
||||
\IPS\Db::i()->delete( 'core_login_failures', [ 'login_member_id IS NOT NULL' ] );
|
||||
Member::updateAllMembers( array( 'failed_login_count' => 0 ) );
|
||||
Db::i()->delete( 'core_login_failures', [ 'login_member_id IS NOT NULL' ] );
|
||||
|
||||
/* disable task */
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), "`key`='unlockmembers'" );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), "`key`='unlockmembers'" );
|
||||
}
|
||||
else if ( $values['ipb_bruteforce_attempts'] > 0 )
|
||||
{
|
||||
/* enable task */
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), "`key`='unlockmembers'" );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), "`key`='unlockmembers'" );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__login_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=login&tab=settings' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__login_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=settings&controller=login&tab=settings' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -344,18 +377,18 @@ class _login extends \IPS\Node\Controller
|
||||
/**
|
||||
* HTTPS check
|
||||
*
|
||||
* @return null
|
||||
* @return void
|
||||
*/
|
||||
protected function httpsCheck()
|
||||
protected function httpsCheck() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::external( 'https://' . mb_substr( \IPS\Settings::i()->base_url, 7 ) )->request()->get();
|
||||
\IPS\Output::i()->output = $response;
|
||||
$response = Url::external( 'https://' . mb_substr( Settings::i()->base_url, 7 ) )->request()->get();
|
||||
Output::i()->output = $response;
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->message( $e->getMessage() ?: '500_error_title', 'error' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->message( $e->getMessage() ?: '500_error_title', 'error' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,60 +397,81 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _registration()
|
||||
protected function _registration() : string
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'registration_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'registration_settings' );
|
||||
|
||||
/* Check SSO Extensions for overloads */
|
||||
$disabledSettings = $appBlocks = [];
|
||||
$ssoSettings = [ 'allow_reg', 'allow_reg_target' ];
|
||||
foreach( Application::allExtensions( 'core', 'SSO', FALSE ) as $app => $ext )
|
||||
{
|
||||
/* @var SSOAbstract $ext */
|
||||
if( $ext->isEnabled() )
|
||||
{
|
||||
foreach( array_keys( $ext->overrideSettings() ) as $settingKey )
|
||||
{
|
||||
if( !in_array( $settingKey, $ssoSettings ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$appBlocks[ $app ] = Member::loggedIn()->language()->addToStack( '__app_' . explode( '_', $app )[0], FALSE );
|
||||
$disabledSettings[ $settingKey ] = $settingKey;
|
||||
Member::loggedIn()->language()->words[ $settingKey . '_desc'] = Member::loggedIn()->language()->addToStack( 'sso_setting_override', FALSE, [ 'pluralize' => [ count( $appBlocks ) ],'htmlsprintf' => [ Member::loggedIn()->language()->formatList( $appBlocks ) ] ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form = new Form();
|
||||
$form->addHeader('registration_standard_settings');
|
||||
$form->addMessage('registration_standard_settings_blurb');
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'allow_reg', \IPS\Login::registrationType(), FALSE, array(
|
||||
'options' => array(
|
||||
$form->addHtml( Theme::i()->getTemplate( 'forms' )->blurb( 'registration_standard_settings_blurb', true, true ) );
|
||||
$form->add( new Radio( 'allow_reg', LoginClass::registrationType(), FALSE, [
|
||||
'options' => [
|
||||
'normal' => 'allow_reg_normal',
|
||||
'full' => 'allow_reg_full',
|
||||
'redirect' => 'allow_reg_redirect',
|
||||
'disabled' => 'allow_reg_disabled'
|
||||
),
|
||||
'toggles' => array(
|
||||
'normal' => array( 'allow_reg_normal_warning' ),
|
||||
'full' => array( 'minimum_age', 'use_coppa' ),
|
||||
'redirect' => array( 'allow_reg_target' )
|
||||
),
|
||||
'disabled' => \IPS\Login\Handler::findMethod( 'IPS\Login\Handler\Standard' ) ? array() : array( 'normal', 'full' )
|
||||
) ) );
|
||||
],
|
||||
'toggles' => [
|
||||
'normal' => [ 'allow_reg_normal_warning' ],
|
||||
'full' => [ 'minimum_age', 'use_coppa' ],
|
||||
'redirect' => [ 'allow_reg_target' ]
|
||||
],
|
||||
'disabled' => isset( $disabledSettings['allow_reg'] ) ? TRUE : ( Handler::findMethod( 'IPS\Login\Handler\Standard' ) ? [] : [ 'normal', 'full' ] )
|
||||
] ) );
|
||||
|
||||
/* Do we have required custom fields? */
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_pfields_data', array( 'pf_not_null != 0 and pf_show_on_reg=1' ) )->first() )
|
||||
if ( Db::i()->select( 'COUNT(*)', 'core_pfields_data', array( 'pf_not_null != 0 and pf_show_on_reg=1' ) )->first() )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['allow_reg_normal_warning'] = \IPS\Member::loggedIn()->language()->addToStack( 'allow_reg_normal_desc_required_warning' );
|
||||
Member::loggedIn()->language()->words['allow_reg_normal_warning'] = Member::loggedIn()->language()->addToStack( 'allow_reg_normal_desc_required_warning' );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'allow_reg_target', \IPS\Settings::i()->allow_reg_target, NULL, array(), function( $val )
|
||||
|
||||
$form->add( new FormUrl( 'allow_reg_target', Settings::i()->allow_reg_target, NULL, [ 'disabled' => isset( $disabledSettings['allow_reg_target'] ) ], function( $val )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->allow_red === 'redirect' )
|
||||
if ( !$val and Request::i()->allow_red === 'redirect' )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
throw new DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'allow_reg_target' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'minimum_age', \IPS\Settings::i()->minimum_age, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'any_age' ), NULL, NULL, NULL, 'minimum_age' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'use_coppa', \IPS\Settings::i()->use_coppa, FALSE, array( 'togglesOn' => array( 'coppa_fax', 'coppa_address' ) ), NULL, NULL, NULL, 'use_coppa' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Tel( 'coppa_fax', \IPS\Settings::i()->coppa_fax, FALSE, array(), NULL, NULL, NULL, 'coppa_fax' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'coppa_address', \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->coppa_address ), FALSE, array(), NULL, NULL, NULL, 'coppa_address' ) );
|
||||
$form->add( new Number( 'minimum_age', Settings::i()->minimum_age, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'any_age' ), NULL, NULL, NULL, 'minimum_age' ) );
|
||||
$form->add( new YesNo( 'use_coppa', Settings::i()->use_coppa, FALSE, array( 'togglesOn' => array( 'coppa_fax', 'coppa_address' ) ), NULL, NULL, NULL, 'use_coppa' ) );
|
||||
$form->add( new Tel( 'coppa_fax', Settings::i()->coppa_fax, FALSE, array(), NULL, NULL, NULL, 'coppa_fax' ) );
|
||||
$form->add( new Address( 'coppa_address', Settings::i()->coppa_address ? GeoLocation::buildFromJson( Settings::i()->coppa_address ) : null, FALSE, array(), NULL, NULL, NULL, 'coppa_address' ) );
|
||||
$form->addHeader('registration_global_settings');
|
||||
$form->addMessage('registration_global_settings_blurb');
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'reg_auth_type', \IPS\Settings::i()->reg_auth_type, FALSE, array(
|
||||
$form->addHtml( Theme::i()->getTemplate( 'forms' )->blurb( 'registration_global_settings_blurb', true, true ) );
|
||||
$form->add( new Radio( 'reg_auth_type', Settings::i()->reg_auth_type, FALSE, array(
|
||||
'options' => array( 'user' => 'reg_auth_type_user', 'admin' => 'reg_auth_type_admin', 'admin_user' => 'reg_auth_type_admin_user', 'none' => 'reg_auth_type_none' ),
|
||||
'toggles' => array( 'user' => array( 'validate_day_prune' ), 'admin_user' => array( 'validate_day_prune' ) )
|
||||
), NULL, NULL, NULL, 'reg_auth_type' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'validate_day_prune', \IPS\Settings::i()->validate_day_prune, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'validate_day_prune' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'allowed_reg_email', explode( ',', \IPS\Settings::i()->allowed_reg_email ), FALSE, array( 'placeholder' => 'mycompany.com' ), function( $value ) {
|
||||
$form->add( new Interval( 'validate_day_prune', Settings::i()->validate_day_prune, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'validate_day_prune' ) );
|
||||
$form->add( new Stack( 'allowed_reg_email', explode( ',', Settings::i()->allowed_reg_email ), FALSE, array( 'placeholder' => 'mycompany.com' ), function( $value ) {
|
||||
if( isset( $value[0] ) AND mb_stripos( $value[0], '@' ) )
|
||||
{
|
||||
throw new \DomainException( 'allowed_reg_email_email_detected' );
|
||||
throw new DomainException( 'allowed_reg_email_email_detected' );
|
||||
}
|
||||
}, NULL, NULL ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'force_reg_terms', \IPS\Settings::i()->force_reg_terms, FALSE, array( 'options' => array(
|
||||
$form->add( new Radio( 'force_reg_terms', Settings::i()->force_reg_terms, FALSE, array( 'options' => array(
|
||||
'0' => 'force_reg_terms_0',
|
||||
'1' => 'force_reg_terms_1',
|
||||
) ) ) );
|
||||
@@ -426,29 +480,26 @@ class _login extends \IPS\Node\Controller
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Save */
|
||||
if ( isset( $values['allowed_reg_email'] ) and \is_array( $values['allowed_reg_email'] ) )
|
||||
if ( isset( $values['allowed_reg_email'] ) and is_array( $values['allowed_reg_email'] ) )
|
||||
{
|
||||
$values['allowed_reg_email'] = implode( ',', $values['allowed_reg_email'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['coppa_address'] ) AND ( $values['coppa_address'] instanceof \IPS\GeoLocation ) )
|
||||
if ( isset( $values['coppa_address'] ) AND ( $values['coppa_address'] instanceof GeoLocation ) )
|
||||
{
|
||||
$values['coppa_address'] = json_encode( $values['coppa_address'] );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplogs__registration_settings' );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
Session::i()->log( 'acplogs__registration_settings' );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=login&tab=registration' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=settings&controller=login&tab=registration' ), 'saved' );
|
||||
}
|
||||
$desc = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack('registration_default_group_info', NULL, [ 'sprintf' => [\IPS\Member\Group::load( \IPS\Settings::i()->member_group )->formattedName ] ] ), 'info' );
|
||||
$desc = Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack('registration_default_group_info', NULL, [ 'sprintf' => [Group::load( Settings::i()->member_group )->formattedName ] ] ), 'none i-border-radius_0' );
|
||||
|
||||
/* Display */
|
||||
return (string) $desc . $form;
|
||||
return $desc . $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,74 +507,103 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _accountsettings()
|
||||
protected function _accountsettings() : string
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'login_account_management' );
|
||||
|
||||
Dispatcher::i()->checkAcpPermission( 'login_account_management' );
|
||||
|
||||
/* Check SSO Extensions for overloads */
|
||||
$disabledSettings = $appBlocks = [];
|
||||
$ssoSettings = [ 'allow_email_changes', 'allow_email_changes_target', 'allow_password_changes', 'allow_password_changes_target', 'allow_forgot_password', 'allow_forgot_password_target' ];
|
||||
|
||||
foreach( Application::allExtensions( 'core', 'SSO', FALSE ) as $app => $ext )
|
||||
{
|
||||
/* @var SSOAbstract $ext */
|
||||
if( $ext->isEnabled() )
|
||||
{
|
||||
foreach( array_keys( $ext->overrideSettings() ) as $settingKey )
|
||||
{
|
||||
if( !in_array( $settingKey, $ssoSettings ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$appBlocks[ $settingKey ][] = Member::loggedIn()->language()->addToStack( '__app_' . explode( '_', $app )[0], FALSE );
|
||||
$disabledSettings[ $settingKey ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $appBlocks as $sKey => $apps )
|
||||
{
|
||||
Member::loggedIn()->language()->words[ $sKey . '_desc'] = Member::loggedIn()->language()->addToStack( 'sso_setting_override', FALSE, [ 'pluralize' => [ count( $apps ) ],'htmlsprintf' => [ Member::loggedIn()->language()->formatList( $apps ) ] ] );
|
||||
}
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form = new Form();
|
||||
$form->addHeader( 'security_header_accounts' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'password_strength_meter', \IPS\Settings::i()->password_strength_meter, FALSE, array( 'togglesOn' => array( 'password_strength_meter_enforce' ) ), NULL, NULL, NULL, 'password_strength_meter' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'password_strength_meter_enforce', \IPS\Settings::i()->password_strength_meter_enforce, FALSE, array( 'togglesOn' => array( 'password_strength_option' ) ), NULL, NULL, NULL, 'password_strength_meter_enforce' ) );
|
||||
$form->add( new YesNo( 'password_strength_meter', Settings::i()->password_strength_meter, FALSE, array( 'togglesOn' => array( 'password_strength_meter_enforce' ) ), NULL, NULL, NULL, 'password_strength_meter' ) );
|
||||
$form->add( new YesNo( 'password_strength_meter_enforce', Settings::i()->password_strength_meter_enforce, FALSE, array( 'togglesOn' => array( 'password_strength_option' ) ), NULL, NULL, NULL, 'password_strength_meter_enforce' ) );
|
||||
$strengthOptions = array(
|
||||
'3' => 'strength_3',
|
||||
'4' => 'strength_4',
|
||||
'5' => 'strength_5',
|
||||
);
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'password_strength_option', \IPS\Settings::i()->password_strength_option, FALSE, array( 'options' => $strengthOptions ), NULL, NULL, NULL, 'password_strength_option' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'device_management', \IPS\Settings::i()->device_management, FALSE ) );
|
||||
$form->add( new Radio( 'password_strength_option', Settings::i()->password_strength_option, FALSE, array( 'options' => $strengthOptions ), NULL, NULL, NULL, 'password_strength_option' ) );
|
||||
$form->add( new YesNo( 'device_management', Settings::i()->device_management, FALSE ) );
|
||||
$form->addHeader('account_management_email_pass');
|
||||
$form->addMessage('account_management_email_pass_blurb');
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'allow_email_changes', \IPS\Settings::i()->allow_email_changes, FALSE, array(
|
||||
'options' => array(
|
||||
$form->addHtml( Theme::i()->getTemplate( 'forms' )->blurb( 'account_management_email_pass_blurb', true, true ) );
|
||||
$form->add( new Radio( 'allow_email_changes', Settings::i()->allow_email_changes, FALSE, [
|
||||
'options' => [
|
||||
'normal' => 'allow_email_changes_normal',
|
||||
'redirect' => 'allow_email_changes_redirect',
|
||||
'disabled' => 'allow_email_changes_disabled',
|
||||
),
|
||||
'toggles' => array(
|
||||
'redirect' => array( 'allow_email_changes_target' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'allow_email_changes_target', \IPS\Settings::i()->allow_email_changes_target, NULL, array(), function( $val )
|
||||
],
|
||||
'toggles' => [
|
||||
'redirect' => [ 'allow_email_changes_target' ]
|
||||
],
|
||||
'disabled' => isset( $disabledSettings['allow_email_changes'] )
|
||||
] ) );
|
||||
$form->add( new FormUrl( 'allow_email_changes_target', Settings::i()->allow_email_changes_target, NULL, [ 'disabled' => isset( $disabledSettings['allow_email_changes_target'] ) ], function( $val )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->allow_email_changes === 'redirect' )
|
||||
if ( !$val and Request::i()->allow_email_changes === 'redirect' )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
throw new DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'allow_email_changes_target' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'allow_password_changes', \IPS\Settings::i()->allow_password_changes, FALSE, array(
|
||||
'options' => array(
|
||||
$form->add( new Radio( 'allow_password_changes', Settings::i()->allow_password_changes, FALSE, [
|
||||
'options' => [
|
||||
'normal' => 'allow_password_changes_normal',
|
||||
'redirect' => 'allow_password_changes_redirect',
|
||||
'disabled' => 'allow_password_changes_disabled',
|
||||
),
|
||||
'toggles' => array(
|
||||
'redirect' => array( 'allow_password_changes_target' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'allow_password_changes_target', \IPS\Settings::i()->allow_password_changes_target, NULL, array(), function( $val )
|
||||
],
|
||||
'toggles' => [
|
||||
'redirect' => [ 'allow_password_changes_target' ]
|
||||
],
|
||||
'disabled' => isset( $disabledSettings['allow_password_changes'] )
|
||||
] ) );
|
||||
$form->add( new FormUrl( 'allow_password_changes_target', Settings::i()->allow_password_changes_target, NULL, [ 'disabled' => isset( $disabledSettings['allow_password_changes_target'] ) ], function( $val )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->allow_password_changes === 'redirect' )
|
||||
if ( !$val and Request::i()->allow_password_changes === 'redirect' )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
throw new DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'allow_password_changes_target' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'allow_forgot_password', \IPS\Settings::i()->allow_forgot_password, FALSE, array(
|
||||
'options' => array(
|
||||
$form->add( new Radio( 'allow_forgot_password', Settings::i()->allow_forgot_password, FALSE, [
|
||||
'options' => [
|
||||
'normal' => 'allow_forgot_password_normal',
|
||||
'handler' => 'allow_forgot_password_handler',
|
||||
'redirect' => 'allow_forgot_password_redirect',
|
||||
'disabled' => 'allow_forgot_password_disabled',
|
||||
),
|
||||
'toggles' => array(
|
||||
'redirect' => array( 'allow_forgot_password_target' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'allow_forgot_password_target', \IPS\Settings::i()->allow_forgot_password_target, NULL, array(), function( $val )
|
||||
],
|
||||
'toggles' => [
|
||||
'redirect' => [ 'allow_forgot_password_target' ]
|
||||
],
|
||||
'disabled' => isset( $disabledSettings['allow_forgot_password'] )
|
||||
] ) );
|
||||
$form->add( new FormUrl( 'allow_forgot_password_target', Settings::i()->allow_forgot_password_target, FALSE, [ 'disabled' => isset( $disabledSettings['allow_forgot_password_target'] ) ], function( $val )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->allow_forgot_password === 'redirect' )
|
||||
if ( !$val and Request::i()->allow_forgot_password === 'redirect' )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
throw new DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'allow_forgot_password_target' ) );
|
||||
|
||||
@@ -534,8 +614,8 @@ class _login extends \IPS\Node\Controller
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__account_management_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=login&tab=accountsettings' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__account_management_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=settings&controller=login&tab=accountsettings' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -547,14 +627,14 @@ class _login extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function forceLogout()
|
||||
protected function forceLogout() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Db::i()->update( 'core_members_known_devices', array( 'login_key' => NULL ) );
|
||||
\IPS\Db::i()->delete( 'core_sessions' );
|
||||
Db::i()->update( 'core_members_known_devices', array( 'login_key' => NULL ) );
|
||||
Db::i()->delete( 'core_sessions' );
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__logout_force' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=login' ), 'logged_out_force' );
|
||||
Session::i()->log( 'acplogs__logout_force' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=settings&controller=login' ), 'logged_out_force' );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user