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

tgapp-resetpassword的Python项目详细描述


关于重置密码

ResetPassword是TurboGears2的可插入应用程序 允许更改用户密码或在丢失时重置密码。

安装

resetpassword既可以从pypi安装,也可以从bitbucket安装:

pip install tgapp-resetpassword

应该只对大多数用户有效

插入重置密码

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

from tgext.pluggable import plug

然后在文件的结尾处使用resetpassword调用plug:

plug(base_config, 'resetpassword')

您可以在 http://localhost:8080/resetpassword

如果使用tgext.mailer则需要插入:

plug(base_config, 'tgext.mailer')

有些选项可以在^{tt1}上设置$ 应用程序的配置文件。 制作激活电子邮件至少需要一个选项 工作:

  • resetpassword.email_sender -> Outgoing mails sender

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

如果不使用turbomailtgext.mailer更多配置 必须设置选项才能使激活电子邮件正常工作:

  • resetpassword.smtp_host -> SMTP server to use to send emails
  • resetpassword.smtp_port -> SMTP server port
  • resetpassword.smtp_login -> Login for authentication on SMTP server
  • resetpassword.smtp_passwd -> Password for authentication on SMTP server

插件选项

插入tgapp-resetpassword时,以下选项 可以传递到插头呼叫:

  • reset_password_form -> Full python path of the form class to use for Reset Password form. By default resetpassword.lib.forms.ResetPasswordForm is used.
  • new_password_form -> Full python path of the form class to use for New Password form. By default registration.lib.forms.NewPasswordForm is used.

因此,插头呼叫可能如下所示:

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

可用挂钩

resetpassword提供了一些钩子 在某些操作期间调用以更改默认值 应用程序的行为:

  • 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 -> Page with password reset request form
  • resetpassword.templates.change_password -> Page with change password request

示例用法(在plug调用之后):

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')

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
文件名的java正则表达式限制名称大小和文件扩展名   Mac上的java Android SDK:jspawnhelper意外退出   java SQL Server 2000到Oracle 12c重音字符   在Java中快速比较大数据集中的值和小数据集中的值   java在代码中的许多地方保留对对象的引用   Java规范中私有内部类的jvm访问标志与反射API不一致?   比较2个int数组中匹配的数字   java Apache Commons数学简化回归:get prediction stderr   安卓 Java SDK管理器因命令行输出中的“flashplayerplugin”而崩溃   JavaSQLite:关闭DB时必须关闭游标吗?   泛型Java设计抽象类声明示例说明   java应用程序在添加片段时崩溃   如何在java中使用注释为字段加载值