Merge pull request #248 from Nienzu/mail_confirmation_optional
Make mail confirmation optional
This commit is contained in:
commit
303be22454
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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('');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
], '');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,14 @@ foreach ($_['groups'] as $group) {
|
|||
</label>
|
||||
</p>
|
||||
|
||||
<h3><?php p($l->t('Disable Email Verification')); ?></h3>
|
||||
<p>
|
||||
<input type="checkbox" id="disable_email_verification" class="checkbox" name="disable_email_verification" <?php if ($_['disable_email_verification'] === 'yes') {
|
||||
echo ' checked';
|
||||
} ?>>
|
||||
<label for="disable_email_verification"><?php p($l->t('Let user can register directly without email verification')); ?></label>
|
||||
</p>
|
||||
|
||||
<h3><?php p($l->t('Allowed email domains')); ?></h3>
|
||||
<p>
|
||||
<label>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,12 @@ style('registration', 'style');
|
|||
<img id="email-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/mail.svg')); ?>" alt=""/>
|
||||
</p>
|
||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" />
|
||||
<input type="submit" id="submit" value="<?php p($l->t('Request verification link')); ?>" />
|
||||
<input type="submit" id="submit" value="<?php
|
||||
if ($_['disable_email_verification'] === 'yes') {
|
||||
p($l->t('Continue'));
|
||||
} else {
|
||||
p($l->t('Request verification link'));
|
||||
}?>" />
|
||||
|
||||
<a id="lost-password-back" href="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('core.login.showLoginForm')) ?>">
|
||||
<?php p($l->t('Back to login')); ?>
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue