diff --git a/lib/Controller/RegisterController.php b/lib/Controller/RegisterController.php index 040a4d3..3f83d4a 100644 --- a/lib/Controller/RegisterController.php +++ b/lib/Controller/RegisterController.php @@ -99,6 +99,7 @@ class RegisterController extends Controller { $params = [ 'email' => $email, 'message' => $message ?: $emailHint, + 'disable_email_verification' => $this->config->getAppValue($this->appName, 'disable_email_verification', 'no') ]; return new TemplateResponse('registration', 'form/email', $params, 'guest'); } @@ -126,6 +127,18 @@ class RegisterController extends Controller { $registration = $this->registrationService->createRegistration($email); } + if ($this->config->getAppValue($this->appName, 'disable_email_verification', 'no') === 'yes') { + return new RedirectResponse( + $this->urlGenerator->linkToRoute( + 'registration.register.showUserForm', + [ + 'secret' => $registration->getClientSecret(), + 'token' => $registration->getToken() + ] + ) + ); + } + try { $this->mailService->sendTokenByMail($registration); } catch (RegistrationException $e) { diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 889c1e2..d939fd9 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -55,7 +55,8 @@ class SettingsController extends Controller { ?bool $admin_approval_required, ?bool $email_is_login, ?bool $domains_is_blocklist, - ?bool $show_domains) { + ?bool $show_domains, + ?bool $disable_email_verification) { // handle domains if (($allowed_domains === '') || ($allowed_domains === null)) { $this->config->deleteAppValue($this->appName, 'allowed_domains'); @@ -67,6 +68,7 @@ class SettingsController extends Controller { $this->config->setAppValue($this->appName, 'email_is_login', $email_is_login ? 'yes' : 'no'); $this->config->setAppValue($this->appName, 'domains_is_blocklist', $domains_is_blocklist ? 'yes' : 'no'); $this->config->setAppValue($this->appName, 'show_domains', $show_domains ? 'yes' : 'no'); + $this->config->setAppValue($this->appName, 'disable_email_verification', $disable_email_verification ? 'yes' : 'no'); // handle groups $groups = $this->groupmanager->search(''); diff --git a/lib/Service/RegistrationService.php b/lib/Service/RegistrationService.php index bc71ac4..65bde42 100644 --- a/lib/Service/RegistrationService.php +++ b/lib/Service/RegistrationService.php @@ -142,7 +142,7 @@ class RegistrationService { $registration->setEmail($email); $registration->setUsername($username); $registration->setDisplayname($displayname); - if ($password !== "") { + if ($password !== '') { $password = $this->crypto->encrypt($password); $registration->setPassword($password); } diff --git a/lib/Settings/RegistrationSettings.php b/lib/Settings/RegistrationSettings.php index 42a35df..b783dd7 100644 --- a/lib/Settings/RegistrationSettings.php +++ b/lib/Settings/RegistrationSettings.php @@ -63,6 +63,7 @@ class RegistrationSettings implements ISettings { $emailIsLogin = $this->config->getAppValue($this->appName, 'email_is_login', 'no'); $domainsIsBlocklist = $this->config->getAppValue($this->appName, 'domains_is_blocklist', 'no'); $showDomains = $this->config->getAppValue($this->appName, 'show_domains', 'no'); + $disableEmailVerification = $this->config->getAppValue($this->appName, 'disable_email_verification', 'no'); return new TemplateResponse('registration', 'admin', [ 'groups' => $groupIds, @@ -72,6 +73,7 @@ class RegistrationSettings implements ISettings { 'email_is_login' => $emailIsLogin, 'domains_is_blocklist' => $domainsIsBlocklist, 'show_domains' => $showDomains, + 'disable_email_verification' => $disableEmailVerification, ], ''); } diff --git a/templates/admin.php b/templates/admin.php index 0bb6efe..a04270d 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -22,6 +22,14 @@ foreach ($_['groups'] as $group) {

+

t('Disable Email Verification')); ?>

+

+ > + +

+

t('Allowed email domains')); ?>

- + t('Back to login')); ?> diff --git a/tests/Unit/Controller/RegisterControllerTest.php b/tests/Unit/Controller/RegisterControllerTest.php index 896f209..25ea874 100644 --- a/tests/Unit/Controller/RegisterControllerTest.php +++ b/tests/Unit/Controller/RegisterControllerTest.php @@ -125,6 +125,7 @@ class RegisterControllerTest extends TestCase { public function testShowEmailForm(string $email, string $message): void { $controller = $this->getController(); $response = $controller->showEmailForm($email, $message); + $disable_email_verification = $this->config->getAppValue('registration', 'disable_email_verification', 'no'); self::assertSame(TemplateResponse::RENDER_AS_GUEST, $response->getRenderAs()); self::assertSame('form/email', $response->getTemplateName()); @@ -132,6 +133,7 @@ class RegisterControllerTest extends TestCase { self::assertSame([ 'email' => $email, 'message' => $message, + 'disable_email_verification' => $disable_email_verification, ], $response->getParams()); }