Adds a setting to disable first time wizard for new users (#5938)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -568,6 +568,9 @@ final class Configuration implements ConfigurationInterface
|
||||
->booleanNode('registration')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
->booleanNode('wizard')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->booleanNode('password_reset')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user