Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/registration.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornienzu <ibqqz0602@gmail.com>2020-10-13 07:06:54 +0300
committernienzu <ibqqz0602@gmail.com>2020-10-20 06:43:33 +0300
commitbdb40a2d113120515e96421d474b8106dbfbf964 (patch)
treeca5104f7e9f2a2cd7c2bdff498d0f9a747d64897 /lib
parentab61503ef34caa44316905834f3c2f811518c4a0 (diff)
Make mail confirmation optional
Signed-off-by: nienzu <ibqqz0602@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/RegisterController.php35
-rw-r--r--lib/Controller/SettingsController.php4
-rw-r--r--lib/Settings/RegistrationSettings.php2
3 files changed, 29 insertions, 12 deletions
diff --git a/lib/Controller/RegisterController.php b/lib/Controller/RegisterController.php
index 040a4d3..b325a42 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,18 +127,30 @@ class RegisterController extends Controller {
$registration = $this->registrationService->createRegistration($email);
}
- try {
- $this->mailService->sendTokenByMail($registration);
- } catch (RegistrationException $e) {
- return $this->showEmailForm($email, $e->getMessage());
+ 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()
+ ]
+ )
+ );
+ } else {
+ try {
+ $this->mailService->sendTokenByMail($registration);
+ } catch (RegistrationException $e) {
+ return $this->showEmailForm($email, $e->getMessage());
+ }
+
+ return new RedirectResponse(
+ $this->urlGenerator->linkToRoute(
+ 'registration.register.showVerificationForm',
+ ['secret' => $registration->getClientSecret()]
+ )
+ );
}
-
- return new RedirectResponse(
- $this->urlGenerator->linkToRoute(
- 'registration.register.showVerificationForm',
- ['secret' => $registration->getClientSecret()]
- )
- );
}
/**
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/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,
], '');
}