跳转到主要内容

适用于TurboGears2的可插拔应用程序,允许更改用户密码或丢失时重置密码,具有sqla和ming兼容性

项目描述

关于resetpassword

resetpassword是适用于TurboGears2的可插拔应用程序,允许更改用户密码或丢失时重置密码。

安装

resetpassword可以从PyPI或Bitbucket安装

pip install tgapp-resetpassword

应该对大多数用户适用

插入resetpassword

在您的应用程序 config/app_cfg.py 中导入 plug

from tgext.pluggable import plug

然后在文件的 末尾 调用plug与resetpassword

plug(base_config, 'resetpassword')

您将能够通过 http://localhost:8080/resetpassword 访问插入的应用程序。

如果您使用 tgext.mailer,则需要插入它

plug(base_config, 'tgext.mailer')

一些选项可以在您的应用程序的 .ini 配置文件中设置。至少需要一个选项才能使激活邮件工作

  • resetpassword.email_sender -> 发出邮件的发送者

如果您使用 tgext.mailer,则需要设置一些配置,请在此处查看可用选项: https://github.com/amol-/tgext.mailer

如果您既不使用 TurboMail 也不使用 tgext.mailer,则需要设置更多配置选项才能使激活邮件工作

  • resetpassword.smtp_host -> 发送邮件时使用的SMTP服务器

  • resetpassword.smtp_port -> SMTP服务器端口

  • resetpassword.smtp_login -> SMTP服务器上的认证登录

  • resetpassword.smtp_passwd -> SMTP服务器上的认证密码

插件选项

当插入tgapp-resetpassword时,以下选项可以传递给插件调用

  • reset_password_form -> 用于重置密码表单的表单类的完整Python路径。默认使用resetpassword.lib.forms.ResetPasswordForm

  • new_password_form -> 用于新密码表单的表单类的完整Python路径。默认使用registration.lib.forms.NewPasswordForm

因此,插件调用可能看起来像这样

plug(
    base_config,
    'resetpassword',
    reset_password_form='myproject.lib.resetpassword_forms.ResetPasswordForm',
    new_password_form='myproject.lib.resetpassword_forms.NewPasswordForm',
)

可用的钩子

resetpassword提供了一些钩子,这些钩子将在某些操作期间被调用,以改变应用程序的默认行为

  • resetpassword.on_begin_reset_request(data)

  • resetpassword.on_request(user, email_data, reset_link)

  • resetpassword.before_render_change_password_template(user, deserialized_data)

  • resetpassword.before_redirect(redirect_url)

公开的模板

resetpassword使用的模板,并且可以用tgext.pluggable.replace_template替换,包括

  • resetpassword.templates.index -> 包含密码重置请求表单的页面

  • resetpassword.templates.change_password -> 包含更改密码请求的页面

示例用法(插件调用之后)

from tgext.pluggable import replace_template
replace_template(base_config, 'resetpassword.templates.index', 'myproject.templates.reset_password')
replace_template(base_config, 'resetpassword.templates.change_password', 'myproject.templates.change_password')

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

tgapp-resetpassword-0.2.7.tar.gz (15.1 kB 查看散列)

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面