当前位置: 首页>>代码示例>>Python>>正文


Python User.load_from_email方法代码示例

本文整理汇总了Python中app.userprofile.User.load_from_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.load_from_email方法的具体用法?Python User.load_from_email怎么用?Python User.load_from_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.userprofile.User的用法示例。


在下文中一共展示了User.load_from_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reset_password_request

# 需要导入模块: from app.userprofile import User [as 别名]
# 或者: from app.userprofile.User import load_from_email [as 别名]
def reset_password_request() -> str:
    """
        Show a form to request resetting the password and process it upon submission.

        :return: The HTML response.
    """

    form = EmailForm()
    if form.validate_on_submit():
        user = User.load_from_email(form.email.data)
        if user is not None:
            token = user.send_password_reset_email()
        else:
            # Create a fake token to get the validity.
            token = ChangeEmailAddressToken()

        validity = token.get_validity(in_minutes=True)

        # Display a success message even if the specified address does not belong to a user account. Otherwise,
        # infiltrators could deduce if an account exists and use this information for attacks.
        flash(_('An email has been sent to the specified address. Please be aware that the included link for resetting \
                the password is only valid for %(validity)d minutes.', validity=validity))
        return redirect(url_for('userprofile.login'))

    return render_template('userprofile/reset_password_request.html', title=_('Forgot Your Password?'), form=form)
开发者ID:BMeu,项目名称:Aerarium,代码行数:27,代码来源:password_reset.py

示例2: __call__

# 需要导入模块: from app.userprofile import User [as 别名]
# 或者: from app.userprofile.User import load_from_email [as 别名]
    def __call__(self, form: Form, field: Field) -> None:
        """
            Execute the validator.

            :param form: The form to which the field belongs.
            :param field: The field to which this validator is attached.
            :raise ValidationError: In case the validation fails.
        """
        email = field.data
        if not email:
            return

        # If there already is a user with that email address and this user is not the current user, this is an error.
        user = User.load_from_email(email)
        if user and user != current_user:
            raise ValidationError(self.message)
开发者ID:BMeu,项目名称:Aerarium,代码行数:18,代码来源:forms.py


注:本文中的app.userprofile.User.load_from_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。