heimrichhannot / contao-backend-lost-password-bundle
本组件为Contao CMS后端提供找回密码功能。
1.7.0
2024-05-27 14:24 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.13 || ^5.0
- heimrichhannot/contao-utils-bundle: ^2.237 || ^3.3
- symfony/config: >=3.4
- symfony/dependency-injection: >=3.4
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: 1.1.*
- friendsofphp/php-cs-fixer: ^2.2
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/php-token-stream: ^1.4|^2.0|^3.0
- phpunit/phpunit: >=6.0 <6.5
- phpunit/phpunit-mock-objects: ^4.0|^5.0
- satooshi/php-coveralls: ^2.0
- symfony/phpunit-bridge: ^3.2
README
本组件为Contao CMS后端提供找回密码功能。
功能
- 如果客户忘记了旧密码,就再也不需要发送新密码了。:-)
- 请求新密码后,将密码重置链接发送到用户的电子邮件。
- 在设置中选择邮件发送传输方式。
安装
- 通过composer安装:
composer require heimrichhannot/contao-backend-lost-password-bundle
并更新您的数据库。 - 如果您希望自动将找回密码链接添加到后端登录模板中,请将
huh_backend_lost_password.add_to_template
设置为 true。
# config/config.yml huh_backend_lost_password: add_to_template: true
自定义
使用通知中心
您可以使用 通知中心 来发送密码请求。
- 创建一个类型为
User: Lost password
的通知,收件人为##recipient_email##
,内容包含##link##
(密码重置页面的链接)。您还可以使用以下附加令牌:##domain##
和##user_*##
中的用户数据。 - 在您的项目配置中设置通知的id为
huh_backend_lost_password.nc_notification
。
# config/config.yml huh_backend_lost_password: nc_notification: 5
在自定义模板中的使用
您可以通过调用 BackendLostPasswortManager->getLostPasswordLink()
在您想要插入找回密码链接的自定义登录模板中插入链接。
<!-- ... -->
<div class="widget">
<label for="password"><?= $this->password ?></label>
<input type="password" name="password" id="password" class="tl_text" value="" placeholder="<?= $this->password ?>" required>
</div>
<?= System::getContainer()->get(\HeimrichHannot\BackendLostPasswordBundle\Manager\BackendLostPasswordManager::class)->getLostPasswordLink() ?>
<div class="submit_container cf">
<button type="submit" name="login" id="login" class="tl_submit"><?= $this->loginButton ?></button>
<a href="<?= $this->route('contao_root') ?>" class="footer_preview"><?= $this->feLink ?> ›</a>
</div>
<!-- ... -->
调整电子邮件文本
提示:您还可以通过在您的 config.yml 中设置id来设置通知中心消息(见下文)。
简单地覆盖以下 $GLOBALS
条目
$GLOBALS['TL_LANG']['MSC']['backendLostPassword']['messageSubjectResetPassword']
$GLOBALS['TL_LANG']['MSC']['backendLostPassword']['messageBodyResetPassword']
配置参考
# Default configuration for extension with alias: "huh_backend_lost_password" huh_backend_lost_password: # If true, that backend lost password link will be automatically added to the backed login template. Default false. Will be true in the next major version! add_to_template: false # The numeric ID of the notification center notification which is sent for resetting the password. nc_notification: false