remove user registration settings (#3832)

* can be re-activated through kimai.yaml
This commit is contained in:
Kevin Papst
2023-02-07 19:36:10 +01:00
committed by GitHub
parent 8095ae298f
commit d481f68266
9 changed files with 62 additions and 41 deletions

View File

@@ -87,7 +87,7 @@
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "9.5.*",
"symfony/browser-kit": "^6.0",
"symfony/css-selector": "^6.0",
"symfony/debug-bundle": "^6.0",

40
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "11d70b2ed4a4024ab1fb5d7e9bd8e436",
"content-hash": "bfeea56e227232b40a907b0c514f7db2",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -10720,16 +10720,16 @@
},
{
"name": "dama/doctrine-test-bundle",
"version": "v7.2.0",
"version": "v7.2.1",
"source": {
"type": "git",
"url": "https://github.com/dmaicher/doctrine-test-bundle.git",
"reference": "91abe52540370d596199a79eff3d823d5b81d41d"
"reference": "175b47153609a369117d97d36049b8a8c3b69dc1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dmaicher/doctrine-test-bundle/zipball/91abe52540370d596199a79eff3d823d5b81d41d",
"reference": "91abe52540370d596199a79eff3d823d5b81d41d",
"url": "https://api.github.com/repos/dmaicher/doctrine-test-bundle/zipball/175b47153609a369117d97d36049b8a8c3b69dc1",
"reference": "175b47153609a369117d97d36049b8a8c3b69dc1",
"shasum": ""
},
"require": {
@@ -10781,9 +10781,9 @@
],
"support": {
"issues": "https://github.com/dmaicher/doctrine-test-bundle/issues",
"source": "https://github.com/dmaicher/doctrine-test-bundle/tree/v7.2.0"
"source": "https://github.com/dmaicher/doctrine-test-bundle/tree/v7.2.1"
},
"time": "2023-02-05T09:12:26+00:00"
"time": "2023-02-07T10:02:27+00:00"
},
{
"name": "doctrine/data-fixtures",
@@ -11346,16 +11346,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.9.14",
"version": "1.9.16",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "e5fcc96289cf737304286a9b505fbed091f02e58"
"reference": "922e2689bb180575d0f57de0443c431a5a698e8f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e5fcc96289cf737304286a9b505fbed091f02e58",
"reference": "e5fcc96289cf737304286a9b505fbed091f02e58",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/922e2689bb180575d0f57de0443c431a5a698e8f",
"reference": "922e2689bb180575d0f57de0443c431a5a698e8f",
"shasum": ""
},
"require": {
@@ -11385,7 +11385,7 @@
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.9.14"
"source": "https://github.com/phpstan/phpstan/tree/1.9.16"
},
"funding": [
{
@@ -11401,7 +11401,7 @@
"type": "tidelift"
}
],
"time": "2023-01-19T10:47:09+00:00"
"time": "2023-02-07T10:42:21+00:00"
},
{
"name": "phpstan/phpstan-doctrine",
@@ -11964,16 +11964,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.6.3",
"version": "9.5.28",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555"
"reference": "954ca3113a03bf780d22f07bf055d883ee04b65e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/954ca3113a03bf780d22f07bf055d883ee04b65e",
"reference": "954ca3113a03bf780d22f07bf055d883ee04b65e",
"shasum": ""
},
"require": {
@@ -12015,7 +12015,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "9.6-dev"
"dev-master": "9.5-dev"
}
},
"autoload": {
@@ -12046,7 +12046,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.3"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.28"
},
"funding": [
{
@@ -12062,7 +12062,7 @@
"type": "tidelift"
}
],
"time": "2023-02-04T13:37:15+00:00"
"time": "2023-01-14T12:32:24+00:00"
},
{
"name": "sebastian/cli-parser",

View File

@@ -84,6 +84,7 @@ final class Version20230126002049 extends AbstractMigration
$this->addSql("UPDATE kimai2_user_preferences SET `name` = 'update_browser_title' WHERE `name` = 'theme.update_browser_title'");
$this->addSql("UPDATE kimai2_configuration SET `value` = '15' WHERE `name` = 'timesheet.time_increment' and `value` = '0'");
$this->addSql("UPDATE kimai2_configuration SET `value` = '5' WHERE `name` = 'timesheet.time_increment' and `value` IN ('1', '2', '3', '4')");
$this->addSql("UPDATE kimai2_configuration SET `value` = '0' WHERE `name` = 'user.registration'");
$this->addSql("UPDATE kimai2_roles SET `name` = UPPER(`name`)");
$this->addSql("UPDATE kimai2_invoice_templates SET `renderer` = 'service-date' WHERE `renderer` = 'freelancer'");
$this->addSql("UPDATE kimai2_invoice_templates SET `renderer` = 'invoice' WHERE `renderer` = 'default'");

View File

@@ -1590,11 +1590,6 @@ parameters:
count: 1
path: src/Controller/Security/SelfRegistrationController.php
-
message: "#^Cannot call method setEnabled\\(\\) on App\\\\Form\\\\Model\\\\Configuration\\|null\\.$#"
count: 3
path: src/Controller/SystemConfigurationController.php
-
message: "#^Parameter \\#1 \\$value of method App\\\\Form\\\\Model\\\\Configuration\\:\\:setValue\\(\\) expects bool\\|int\\|object\\|string\\|null, bool\\|float\\|int\\|string given\\.$#"
count: 1

View File

@@ -278,13 +278,18 @@ final class SystemConfigurationController extends AbstractController
->setType(IntegerType::class),
]);
$allowRegistration = $this->systemConfiguration->find('features.user_registration');
if ($allowRegistration === false) {
$authentication->getConfigurationByName('user.registration')?->setEnabled(false);
}
if (!$this->systemConfiguration->isSamlActive()) {
$authentication->getConfigurationByName('user.login')->setEnabled(false);
$authentication->getConfigurationByName('user.login')?->setEnabled(false);
}
if (!$this->systemConfiguration->isPasswordResetActive()) {
$authentication->getConfigurationByName('user.password_reset_retry_ttl')->setEnabled(false);
$authentication->getConfigurationByName('user.password_reset_token_ttl')->setEnabled(false);
$authentication->getConfigurationByName('user.password_reset_retry_ttl')?->setEnabled(false);
$authentication->getConfigurationByName('user.password_reset_token_ttl')?->setEnabled(false);
}
return [

View File

@@ -69,19 +69,16 @@ final class AppExtension extends Extension
}
// this should happen always at the end, so bundles do not mess with the base configuration
/* @phpstan-ignore-next-line */
if ($container->hasParameter('kimai.bundles.config')) {
if ($container->hasParameter('kimai.bundles.config')) { // @phpstan-ignore-line
$bundleConfig = $container->getParameter('kimai.bundles.config');
if (!\is_array($bundleConfig)) {
trigger_error('Invalid bundle configuration found, skipping all bundle configuration');
} else {
foreach ($bundleConfig as $key => $value) {
if (\array_key_exists($key, $config)) {
trigger_error(sprintf('Invalid bundle configuration "%s" found, skipping', $key));
continue;
}
$config[$key] = $value;
throw new \Exception('Invalid bundle configuration found, skipping all bundle configuration');
}
foreach ($bundleConfig as $key => $value) {
if (\array_key_exists($key, $config)) {
throw new \Exception(sprintf('Invalid bundle configuration "%s" found, skipping', $key));
}
$config[$key] = $value;
}
}

View File

@@ -55,12 +55,32 @@ final class Configuration implements ConfigurationInterface
->append($this->getQuickEntryNode())
->append($this->getActivityNode())
->append($this->getProjectNode())
->append($this->getFeaturesNode())
->end()
->end();
return $treeBuilder;
}
private function getFeaturesNode(): ArrayNodeDefinition
{
$builder = new TreeBuilder('features');
/** @var ArrayNodeDefinition $node */
$node = $builder->getRootNode();
$node
->addDefaultsIfNotSet()
->children()
// this feature was deactivated in order to deprecate/remove it in the future, very likely not necessary for anyone
->integerNode('user_registration')
->defaultFalse()
->end()
->end()
;
return $node;
}
private function getQuickEntryNode(): ArrayNodeDefinition
{
$builder = new TreeBuilder('quick_entry');

View File

@@ -254,7 +254,7 @@ class AppExtensionTest extends TestCase
public function testWithBundleConfigurationFailsOnDuplicatedKey(): void
{
$this->expectNotice();
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid bundle configuration "timesheet" found, skipping');
$bundleConfig = [
@@ -268,7 +268,7 @@ class AppExtensionTest extends TestCase
public function testWithBundleConfigurationFailsOnNonArray(): void
{
$this->expectNotice();
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid bundle configuration found, skipping all bundle configuration');
$container = $this->getContainer();

View File

@@ -435,6 +435,9 @@ class ConfigurationTest extends TestCase
'allow_duplicate_number' => false,
],
],
'features' => [
'user_registration' => false,
],
];
$this->assertConfig($this->getMinConfig(), $fullDefaultConfig);