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


Python BaseResponse.delete_cookie方法代码示例

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


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

示例1: pin_auth

# 需要导入模块: from werkzeug.wrappers import BaseResponse [as 别名]
# 或者: from werkzeug.wrappers.BaseResponse import delete_cookie [as 别名]
    def pin_auth(self, request):
        """Authenticates with the pin."""
        exhausted = False
        auth = False
        trust = self.check_pin_trust(request.environ)

        # If the trust return value is `None` it means that the cookie is
        # set but the stored pin hash value is bad.  This means that the
        # pin was changed.  In this case we count a bad auth and unset the
        # cookie.  This way it becomes harder to guess the cookie name
        # instead of the pin as we still count up failures.
        bad_cookie = False
        if trust is None:
            self._fail_pin_auth()
            bad_cookie = True

        # If we're trusted, we're authenticated.
        elif trust:
            auth = True

        # If we failed too many times, then we're locked out.
        elif self._failed_pin_auth > 10:
            exhausted = True

        # Otherwise go through pin based authentication
        else:
            entered_pin = request.args.get('pin')
            if entered_pin.strip().replace('-', '') == \
               self.pin.replace('-', ''):
                self._failed_pin_auth = 0
                auth = True
            else:
                self._fail_pin_auth()

        rv = Response(json.dumps({
            'auth': auth,
            'exhausted': exhausted,
        }), mimetype='application/json')
        if auth:
            rv.set_cookie(self.pin_cookie_name, '%s|%s' % (
                int(time.time()),
                hash_pin(self.pin)
            ), httponly=True)
        elif bad_cookie:
            rv.delete_cookie(self.pin_cookie_name)
        return rv
开发者ID:CityPulse,项目名称:pickup-planner,代码行数:48,代码来源:__init__.py


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