-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A central location for the configuration should make it easier to disable certain unwanted functions in SSO plugins.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...es/lib/system/user/authentication/configuration/UserAuthenticationConfiguration.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace wcf\system\user\authentication\configuration; | ||
|
||
/** | ||
* Represents the configuration of the user authentication process. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.1 | ||
*/ | ||
final class UserAuthenticationConfiguration | ||
{ | ||
public function __construct( | ||
public readonly bool $canRegister = true, | ||
public readonly bool $canChangeUsername = true, | ||
public readonly bool $canChangeEmail = true, | ||
public readonly bool $canChangePassword = true, | ||
) { | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...system/user/authentication/configuration/UserAuthenticationConfigurationFactory.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace wcf\system\user\authentication\configuration; | ||
|
||
use wcf\system\event\EventHandler; | ||
use wcf\system\SingletonFactory; | ||
use wcf\system\user\authentication\configuration\event\ConfigurationLoading; | ||
|
||
/** | ||
* Provides the instance of the active configuration of the user authentication process. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.1 | ||
*/ | ||
final class UserAuthenticationConfigurationFactory extends SingletonFactory | ||
{ | ||
private UserAuthenticationConfiguration $configuration; | ||
|
||
#[\Override] | ||
protected function init() | ||
{ | ||
$this->configuration = $this->getDefaultConfiguration(); | ||
|
||
$event = new ConfigurationLoading(); | ||
EventHandler::getInstance()->fire($event); | ||
if ($event->getConfigration()) { | ||
$this->configuration = $event->getConfigration(); | ||
} | ||
} | ||
|
||
public function getConfigration(): UserAuthenticationConfiguration | ||
{ | ||
return $this->configuration; | ||
} | ||
|
||
private function getDefaultConfiguration(): UserAuthenticationConfiguration | ||
{ | ||
return new UserAuthenticationConfiguration( | ||
!\REGISTER_DISABLED, | ||
); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...l/files/lib/system/user/authentication/configuration/event/ConfigurationLoading.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace wcf\system\user\authentication\configuration\event; | ||
|
||
use wcf\system\event\IEvent; | ||
use wcf\system\user\authentication\configuration\UserAuthenticationConfiguration; | ||
|
||
/** | ||
* Indicates the loading of the configuration. | ||
* | ||
* @author Marcel Werk | ||
* @copyright 2001-2024 WoltLab GmbH | ||
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | ||
* @since 6.1 | ||
*/ | ||
final class ConfigurationLoading implements IEvent | ||
{ | ||
private UserAuthenticationConfiguration $configuration; | ||
|
||
public function register(UserAuthenticationConfiguration $configuration): void | ||
{ | ||
if (isset($this->configuration)) { | ||
throw new \BadMethodCallException("A configuration has already been loaded"); | ||
} | ||
|
||
$this->configuration = $configuration; | ||
} | ||
|
||
public function getConfigration(): ?UserAuthenticationConfiguration | ||
{ | ||
return $this->configuration ?? null; | ||
} | ||
} |