Skip to content

Commit 9dc0690

Browse files
committed
refactor: login captcha
1 parent abadff2 commit 9dc0690

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/users/serializers/login.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def login(instance):
4444
username = instance.get('username')
4545
password = instance.get('password')
4646
captcha = instance.get('captcha')
47-
captcha_cache = cache.get(Cache_Version.CAPTCHA.get_key(captcha=captcha),
47+
captcha_cache = cache.get(Cache_Version.CAPTCHA.get_key(captcha=captcha.lower()),
4848
version=Cache_Version.CAPTCHA.get_version())
4949
if captcha_cache is None:
5050
raise AppApiException(1005, _("Captcha code error or expiration"))
@@ -76,6 +76,6 @@ def generate():
7676
image = ImageCaptcha()
7777
data = image.generate(chars)
7878
captcha = base64.b64encode(data.getbuffer())
79-
cache.set(Cache_Version.CAPTCHA.get_key(captcha=chars), chars,
79+
cache.set(Cache_Version.CAPTCHA.get_key(captcha=chars.lower()), chars,
8080
timeout=60, version=Cache_Version.CAPTCHA.get_version())
8181
return {'captcha': 'data:image/png;base64,' + captcha.decode()}

0 commit comments

Comments
 (0)