本文整理匯總了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