Adds a setting to disable first time wizard for new users (#5938)

This commit is contained in:
Tobias Perschon
2026-05-23 18:48:42 +02:00
committed by GitHub
parent eeeeae41e7
commit 8d245ae223
10 changed files with 146 additions and 6 deletions

View File

@@ -370,6 +370,11 @@ final class SystemConfiguration
return $this->getDefaultCurrency();
}
public function isUserWizardActive(): bool
{
return (bool) $this->find('user.wizard');
}
// ========== Timesheet configurations ==========
/*
public function getTimesheetBreakWarningDuration(): int

View File

@@ -546,6 +546,10 @@ final class SystemConfigurationController extends AbstractController
->setLabel('theme.avatar_url')
->setType(YesNoType::class)
->setTranslationDomain('system-configuration'),
(new Configuration('user.wizard'))
->setLabel('user_auth_wizard')
->setType(YesNoType::class)
->setTranslationDomain('system-configuration'),
]),
(new SystemConfigurationModel('theme'))
->setConfiguration([

View File

@@ -568,6 +568,9 @@ final class Configuration implements ConfigurationInterface
->booleanNode('registration')
->defaultFalse()
->end()
->booleanNode('wizard')
->defaultTrue()
->end()
->booleanNode('password_reset')
->defaultTrue()
->end()

View File

@@ -9,6 +9,7 @@
namespace App\EventSubscriber;
use App\Configuration\SystemConfiguration;
use App\Entity\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -23,7 +24,8 @@ class WizardSubscriber implements EventSubscriberInterface
public function __construct(
private UrlGeneratorInterface $urlGenerator,
private AuthorizationCheckerInterface $security,
private TokenStorageInterface $storage
private TokenStorageInterface $storage,
private SystemConfiguration $systemConfiguration
) {
}
@@ -63,6 +65,15 @@ class WizardSubscriber implements EventSubscriberInterface
return;
}
if ($user->requiresPasswordReset()) {
$response = new RedirectResponse($this->urlGenerator->generate('wizard', ['wizard' => 'password']));
$event->setResponse($response);
}
if ($user->isRegularUserOnly() && !$this->systemConfiguration->isUserWizardActive()) {
return;
}
foreach (User::WIZARDS as $wizard) {
if (!$user->hasSeenWizard($wizard)) {
$response = new RedirectResponse($this->urlGenerator->generate('wizard', ['wizard' => $wizard]));
@@ -71,10 +82,5 @@ class WizardSubscriber implements EventSubscriberInterface
return;
}
}
if ($user->requiresPasswordReset()) {
$response = new RedirectResponse($this->urlGenerator->generate('wizard', ['wizard' => 'password']));
$event->setResponse($response);
}
}
}