Commit b405fd73 authored by Tino Goratsch's avatar Tino Goratsch

- fixed the password reset controller action

- send a HTML email when an user requests a new password
parent 9a47f7bb
......@@ -398,7 +398,7 @@ class Mailer
private function addRecipients($recipients, $bcc = false)
{
if (is_array($recipients) === true) {
if (empty($recipients['email']) === false && empty($recipients['name']) === false) {
if (isset($recipients['email'], $recipients['name']) === true) {
$this->addRecipient($recipients['email'], $recipients['name'], $bcc);
} else {
foreach ($recipients as $recipient) {
......
......@@ -141,7 +141,6 @@ class ForgotPwd extends Core\Controller\AbstractFrontendAction
*/
protected function sendPasswordChangeEmail(array $user, $newPassword)
{
$host = $this->request->getHost();
$systemSettings = $this->config->getSettings(Schema::MODULE_NAME);
$subject = $this->translator->t(
......@@ -149,7 +148,7 @@ class ForgotPwd extends Core\Controller\AbstractFrontendAction
'forgot_pwd_mail_subject',
[
'{title}' => $systemSettings['site_title'],
'{host}' => $host
'{host}' => $this->request->getHost()
]
);
$body = $this->translator->t(
......@@ -159,17 +158,22 @@ class ForgotPwd extends Core\Controller\AbstractFrontendAction
'{mail}' => $user['mail'],
'{password}' => $newPassword,
'{title}' => $systemSettings['site_title'],
'{host}' => $host
'{host}' => $this->request->getHost()
]
);
$settings = $this->config->getSettings(Users\Installer\Schema::MODULE_NAME);
return $this->sendEmail->execute(
substr($user['realname'], 0, -2),
$user['mail'],
$settings['mail'],
$subject,
$body
);
$data = (new Core\Mailer\MailerMessage())
->setRecipients([
'name' => $user['realname'],
'email' => $user['mail']
])
->setFrom($settings['mail'])
->setSubject($subject)
->setTemplate('Users/layout.email.forgot_pwd.tpl')
->setBody($body);
return $this->sendEmail->execute($data);
}
}
{extends file="asset:System/layout.email.tpl"}
{block EMAIL_HEAD}
<title>{$mail.title}</title>
{/block}
{block EMAIL_CONTENT}
{$mail.body}
{/block}
......@@ -23,6 +23,13 @@ services:
class: ACP3\Modules\ACP3\Users\Validation\RegistrationFormValidation
parent: core.validator.abstract
users.validation.validation_rules.account_exists_by_email_validation_rule:
class: ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountExistsByEmailValidationRule
arguments:
- '@users.model.userrepository'
tags:
- { name: core.validation.validation_rule }
users.validation.validation_rules.account_not_exists_by_email_validation_rule:
class: ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountNotExistsByEmailValidationRule
arguments:
......@@ -30,6 +37,13 @@ services:
tags:
- { name: core.validation.validation_rule }
users.validation.validation_rules.account_exists_by_name_validation_rule:
class: ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountExistsByNameValidationRule
arguments:
- '@users.model.userrepository'
tags:
- { name: core.validation.validation_rule }
users.validation.validation_rules.account_not_exists_by_name_validation_rule:
class: ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountNotExistsByNameValidationRule
arguments:
......
......@@ -41,7 +41,7 @@
E-Mail-Adresse: {mail}
Passwort: {password}
Bitte ändern Sie, nachdem Sie sich mit obrigem Passwort angemeldet haben, das Passwort zu einem Ihrer Wahl ab.
Bitte ändern Sie, nachdem Sie sich mit obigem Passwort angemeldet haben, das Passwort zu einem Ihrer Wahl ab.
</item>
<item key="forgot_pwd_success">Das neue Passwort wurde erfolgreich an Ihre E-Mail-Adresse versendet.</item>
<item key="frontend_account_edit">Profil bearbeiten</item>
......
......@@ -3,8 +3,8 @@ namespace ACP3\Modules\ACP3\Users\Validation;
use ACP3\Core;
use ACP3\Core\Validation\AbstractFormValidation;
use ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountNotExistsByEmailValidationRule;
use ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountNotExistsByNameValidationRule;
use ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountExistsByEmailValidationRule;
use ACP3\Modules\ACP3\Users\Validation\ValidationRules\AccountExistsByNameValidationRule;
/**
* Class AccountForgotPasswordFormValidation
......@@ -18,9 +18,9 @@ class AccountForgotPasswordFormValidation extends AbstractFormValidation
public function validate(array $formData)
{
if ($this->validator->is(Core\Validation\ValidationRules\EmailValidationRule::class, $formData['nick_mail'])) {
$ruleName = AccountNotExistsByEmailValidationRule::class;
$ruleName = AccountExistsByEmailValidationRule::class;
} else {
$ruleName = AccountNotExistsByNameValidationRule::class;
$ruleName = AccountExistsByNameValidationRule::class;
}
$this->validator
......
<?php
/**
* Copyright (c) 2017 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\Users\Validation\ValidationRules;
class AccountExistsByEmailValidationRule extends AccountNotExistsByEmailValidationRule
{
/**
* @inheritdoc
*/
protected function accountExists($data, $userId)
{
return !parent::accountExists($data, $userId);
}
}
<?php
/**
* Copyright (c) 2017 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\Users\Validation\ValidationRules;
class AccountExistsByNameValidationRule extends AccountNotExistsByNameValidationRule
{
/**
* @inheritdoc
*/
protected function accountExists($data, $userId)
{
return !parent::accountExists($data, $userId);
}
}
......@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Updated the IncludeJs Smarty function to append a query string with the current version of the ACP3 for HTTP cache busting
- Added reCAPATCHA as a new captcha type
- Added the new Smarty function "image" which makes it possible to include an image from the Assets/img folder of a design
- Added theme inheritance based HTML email layouts for the newsletter and contact module
### Changed
- Refactored the captcha system so that it can be extended with different captcha types
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment