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


Python User.by_email方法代码示例

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


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

示例1: render

# 需要导入模块: from pyvac.models import User [as 别名]
# 或者: from pyvac.models.User import by_email [as 别名]
    def render(self):

        if 'submit' in self.request.params:
            email = self.request.params.get('email', '')
            user = User.by_email(self.session, email)
            if user:
                passhash = uuid.uuid4().hex
                date_end = datetime.now() + relativedelta(seconds=86400)
                # create hash entry in database with a TTL of 1 day
                entry = PasswordRecovery(user_id=user.id,
                                         hash=passhash,
                                         date_end=date_end)
                self.session.add(entry)
                self.session.flush()

                # call celery send mail task directly
                from celery.registry import tasks
                from celery.task import subtask
                req_task = tasks['worker_mail']

                data = {
                    'sender': '[email protected]',
                    'target': user.email,
                    'subject': 'Password Recovery',
                    'content': """Hello,

we send you this mail because you requested a password reset, to proceed please click the link below:
%s

Reminder, your login is: %s

""" % (route_url('change_password', self.request, passhash=passhash), user.login)
                }

                subtask(req_task).delay(data=data)

                msg = 'Mail sent to %s for password recovery.' % user.email
                self.request.session.flash('info;%s' % msg)
                return HTTPFound(location=route_url('login', self.request))

        return {}
开发者ID:grigouze,项目名称:pyvac,代码行数:43,代码来源:credentials.py

示例2: render

# 需要导入模块: from pyvac.models import User [as 别名]
# 或者: from pyvac.models.User import by_email [as 别名]
    def render(self):

        if "submit" in self.request.params:
            email = self.request.params.get("email", "")
            user = User.by_email(self.session, email)
            if user:
                passhash = uuid.uuid4().hex
                date_end = datetime.now() + relativedelta(seconds=86400)
                # create hash entry in database with a TTL of 1 day
                entry = PasswordRecovery(user_id=user.id, hash=passhash, date_end=date_end)
                self.session.add(entry)
                self.session.flush()

                # call celery send mail task directly
                from celery.registry import tasks
                from celery.task import subtask

                req_task = tasks["worker_mail"]

                data = {
                    "sender": "[email protected]",
                    "target": user.email,
                    "subject": "Password Recovery",
                    "content": """Hello,

we send you this mail because you requested a password reset, to proceed please click the link below:
%s

Reminder, your login is: %s

"""
                    % (route_url("change_password", self.request, passhash=passhash), user.login),
                }

                subtask(req_task).delay(data=data)

                msg = "Mail sent to %s for password recovery." % user.email
                self.request.session.flash("info;%s" % msg)
                return HTTPFound(location=route_url("login", self.request))

        return {}
开发者ID:doyousoft,项目名称:pyvac,代码行数:43,代码来源:credentials.py


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