Don't mention verification link when the login flow is used

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-04-01 10:48:58 +02:00
parent 4430d2b497
commit afcee9b763
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
4 changed files with 30 additions and 11 deletions

View File

@ -99,7 +99,8 @@ class RegisterController extends Controller {
$params = [ $params = [
'email' => $email, 'email' => $email,
'message' => $message ?: $emailHint, 'message' => $message ?: $emailHint,
'disable_email_verification' => $this->config->getAppValue($this->appName, 'disable_email_verification', 'no') 'disable_email_verification' => $this->config->getAppValue($this->appName, 'disable_email_verification', 'no'),
'is_login_flow' => $this->loginFlowService->isUsingLoginFlow(),
]; ];
return new TemplateResponse('registration', 'form/email', $params, 'guest'); return new TemplateResponse('registration', 'form/email', $params, 'guest');
} }

View File

@ -50,6 +50,8 @@ class MailService {
private $l10n; private $l10n;
/** @var IGroupManager */ /** @var IGroupManager */
private $groupManager; private $groupManager;
/** @var LoginFlowService */
private $loginFlowService;
/** @var ILogger */ /** @var ILogger */
private $logger; private $logger;
/** @var IConfig */ /** @var IConfig */
@ -61,6 +63,7 @@ class MailService {
IL10N $l10n, IL10N $l10n,
IGroupManager $groupManager, IGroupManager $groupManager,
IConfig $config, IConfig $config,
LoginFlowService $loginFlowService,
ILogger $logger) { ILogger $logger) {
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->mailer = $mailer; $this->mailer = $mailer;
@ -68,6 +71,7 @@ class MailService {
$this->defaults = $defaults; $this->defaults = $defaults;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->groupManager = $groupManager; $this->groupManager = $groupManager;
$this->loginFlowService = $loginFlowService;
$this->logger = $logger; $this->logger = $logger;
} }
@ -103,11 +107,17 @@ class MailService {
$template->addHeading($this->l10n->t('Registration')); $template->addHeading($this->l10n->t('Registration'));
$body = $this->l10n->t('Email address verified, you can now complete your registration.'); $body = $this->l10n->t('Email address verified, you can now complete your registration.');
$template->addBodyText( if (!$this->loginFlowService->isUsingLoginFlow()) {
htmlspecialchars($body . ' ' . $this->l10n->t('Click the button below to continue.')), $template->addBodyText(
$body htmlspecialchars($body . ' ' . $this->l10n->t('Click the button below to continue.')),
); $body
);
} else {
$template->addBodyText(
$body
);
}
// if the parameter is set through the settings panel add to body text // if the parameter is set through the settings panel add to body text
$email_verification_hint = $this->config->getAppValue('registration', 'email_verification_hint'); $email_verification_hint = $this->config->getAppValue('registration', 'email_verification_hint');
if (!empty($email_verification_hint)) { if (!empty($email_verification_hint)) {
@ -118,10 +128,12 @@ class MailService {
$this->l10n->t('Verification code: %s', $registration->getToken()) $this->l10n->t('Verification code: %s', $registration->getToken())
); );
$template->addBodyButton( if (!$this->loginFlowService->isUsingLoginFlow()) {
$this->l10n->t('Continue registration'), $template->addBodyButton(
$link $this->l10n->t('Continue registration'),
); $link
);
}
$template->addFooter(); $template->addFooter();
$from = Util::getDefaultEmailAddress('register'); $from = Util::getDefaultEmailAddress('register');

View File

@ -20,9 +20,11 @@ style('registration', 'style');
<input type="submit" id="submit" value="<?php <input type="submit" id="submit" value="<?php
if ($_['disable_email_verification'] === 'yes') { if ($_['disable_email_verification'] === 'yes') {
p($l->t('Continue')); p($l->t('Continue'));
} elseif ($_['is_login_flow']) {
p($l->t('Request verification code'));
} else { } else {
p($l->t('Request verification link')); p($l->t('Request verification link'));
}?>" /> } ?>" />
<a id="lost-password-back" href="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('core.login.showLoginForm')) ?>"> <a id="lost-password-back" href="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('core.login.showLoginForm')) ?>">
<?php p($l->t('Back to login')); ?> <?php p($l->t('Back to login')); ?>

View File

@ -127,6 +127,9 @@ class RegisterControllerTest extends TestCase {
$response = $controller->showEmailForm($email, $message); $response = $controller->showEmailForm($email, $message);
$disable_email_verification = $this->config->getAppValue('registration', 'disable_email_verification', 'no'); $disable_email_verification = $this->config->getAppValue('registration', 'disable_email_verification', 'no');
$this->loginFlowService->method('isUsingLoginFlow')
->willReturn(false);
self::assertSame(TemplateResponse::RENDER_AS_GUEST, $response->getRenderAs()); self::assertSame(TemplateResponse::RENDER_AS_GUEST, $response->getRenderAs());
self::assertSame('form/email', $response->getTemplateName()); self::assertSame('form/email', $response->getTemplateName());
@ -134,6 +137,7 @@ class RegisterControllerTest extends TestCase {
'email' => $email, 'email' => $email,
'message' => $message, 'message' => $message,
'disable_email_verification' => $disable_email_verification, 'disable_email_verification' => $disable_email_verification,
'is_login_flow' => false,
], $response->getParams()); ], $response->getParams());
} }