django-powcaptcha 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_powcaptcha/client.py +11 -5
- {django_powcaptcha-0.0.2.dist-info → django_powcaptcha-0.0.3.dist-info}/METADATA +1 -1
- {django_powcaptcha-0.0.2.dist-info → django_powcaptcha-0.0.3.dist-info}/RECORD +6 -6
- {django_powcaptcha-0.0.2.dist-info → django_powcaptcha-0.0.3.dist-info}/WHEEL +1 -1
- {django_powcaptcha-0.0.2.dist-info → django_powcaptcha-0.0.3.dist-info}/LICENSE +0 -0
- {django_powcaptcha-0.0.2.dist-info → django_powcaptcha-0.0.3.dist-info}/top_level.txt +0 -0
django_powcaptcha/client.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from django.core.cache import cache
|
|
1
2
|
import json
|
|
2
3
|
from urllib.error import HTTPError
|
|
3
4
|
from urllib.request import Request, build_opener
|
|
@@ -31,13 +32,18 @@ def powcaptcha_request(path, params):
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
def get_challenge():
|
|
34
|
-
|
|
35
|
-
response = powcaptcha_request(path, [])
|
|
36
|
-
challenges = json.loads(response.read().decode('utf-8'))
|
|
35
|
+
challenges = cache.get('powcaptcha_challenges')
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
if not challenges or len(challenges) == 0:
|
|
38
|
+
path = 'GetChallenges?difficultyLevel=5'
|
|
39
|
+
response = powcaptcha_request(path, [])
|
|
40
|
+
challenges = json.loads(response.read().decode('utf-8'))
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
challenge = challenges[0]
|
|
43
|
+
challenges.pop(0)
|
|
44
|
+
cache.set('powcaptcha_challenges', challenges, 3600)
|
|
45
|
+
|
|
46
|
+
return challenge
|
|
41
47
|
|
|
42
48
|
|
|
43
49
|
def validate_captcha(challenge: str, nonce: str):
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
django_powcaptcha/__init__.py,sha256=KQ6rfGAMJvwKobMVAn2s_EsL5JpPoMkzoNZg4mT_esk,597
|
|
2
2
|
django_powcaptcha/apps.py,sha256=ShxcNSD7Dl2bnnzb6DCnJ4UcsxxVbXlmCGf9aFKUVz4,146
|
|
3
|
-
django_powcaptcha/client.py,sha256=
|
|
3
|
+
django_powcaptcha/client.py,sha256=AWYE82MUR-DLK7gtGx5Q-MZ4VTBQoMeRt_fr3SdCt_s,1334
|
|
4
4
|
django_powcaptcha/fields.py,sha256=4Kx9RN-oCsoBVzYdenM73UgZqvqo6pISh17mIAMB7rs,200
|
|
5
5
|
django_powcaptcha/forms.py,sha256=gcTDVPdmyXGvkwQjR63wbczF9-nQKWlwsM_WsFWbe8Y,735
|
|
6
6
|
django_powcaptcha/widgets.py,sha256=SqGcmraMRQdbzVav5Hm3CF-6KdA-wiEZI_B0tXayEOk,609
|
|
7
7
|
django_powcaptcha/templates/django_powcaptcha/widget.html,sha256=9H_c66_0kid6qxHhNw-3e3M454hpF9wzJT65QU4hRNs,947
|
|
8
|
-
django_powcaptcha-0.0.
|
|
9
|
-
django_powcaptcha-0.0.
|
|
10
|
-
django_powcaptcha-0.0.
|
|
11
|
-
django_powcaptcha-0.0.
|
|
12
|
-
django_powcaptcha-0.0.
|
|
8
|
+
django_powcaptcha-0.0.3.dist-info/LICENSE,sha256=EaUvjNHHdVXQTD7w9zcrkLZbRcLEnQ6Q0IekrbN3QUg,1509
|
|
9
|
+
django_powcaptcha-0.0.3.dist-info/METADATA,sha256=YL9N7r4L92DICjpqhXXz--1Rhfhx9hzHuQgc1HnEo2s,1846
|
|
10
|
+
django_powcaptcha-0.0.3.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
|
11
|
+
django_powcaptcha-0.0.3.dist-info/top_level.txt,sha256=aEMCJ3_ll_timVB-47n6gL3LGDhHHPkdkv3lnvaJBNQ,18
|
|
12
|
+
django_powcaptcha-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|