mirror of
https://git.wownero.com/wownero/wownero-funding-system.git
synced 2024-08-15 00:53:45 +00:00
Actually make throttling work correctly
This commit is contained in:
parent
3989dbdf8c
commit
523fa1c569
1 changed files with 11 additions and 8 deletions
|
@ -46,16 +46,19 @@ def api_qr_generate(address):
|
|||
"""
|
||||
from funding.factory import cache
|
||||
|
||||
throttling_seconds = 3
|
||||
ip = get_ip()
|
||||
cache_key = 'qr_ip_%s' % ip
|
||||
hit = cache.get(cache_key)
|
||||
if hit and ip not in ['127.0.0.1', 'localhost']:
|
||||
return Response('Wait a bit before generating a new QR', 403)
|
||||
cache.set(cache_key, {}, throttling_seconds)
|
||||
|
||||
qr = QrCodeGenerator()
|
||||
if not qr.exists(address):
|
||||
# create a new QR code
|
||||
ip = get_ip()
|
||||
cache_key = 'qr_ip_%s' % ip
|
||||
hit = cache.get(cache_key)
|
||||
|
||||
if hit and ip not in ['127.0.0.1', 'localhost']:
|
||||
return Response('Wait a bit before generating a new QR', 403)
|
||||
|
||||
throttling_seconds = 3
|
||||
cache.set(cache_key, {'wow': 'kek'}, throttling_seconds)
|
||||
|
||||
created = qr.create(address)
|
||||
if not created:
|
||||
raise Exception('Could not create QR code')
|
||||
|
|
Loading…
Reference in a new issue