Skip to content

Commit 289ebf4

Browse files
authored
fix: Verification code is not case sensitive (#3121)
1 parent 71fdce0 commit 289ebf4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/users/serializers/user_serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def generate():
6464
image = ImageCaptcha()
6565
data = image.generate(chars)
6666
captcha = base64.b64encode(data.getbuffer())
67-
captcha_cache.set(f"LOGIN:{chars}", chars, timeout=5 * 60)
67+
captcha_cache.set(f"LOGIN:{chars.lower()}", chars, timeout=5 * 60)
6868
return 'data:image/png;base64,' + captcha.decode()
6969

7070

@@ -105,7 +105,7 @@ def is_valid(self, *, raise_exception=False):
105105
"""
106106
super().is_valid(raise_exception=True)
107107
captcha = self.data.get('captcha')
108-
captcha_value = captcha_cache.get(f"LOGIN:{captcha}")
108+
captcha_value = captcha_cache.get(f"LOGIN:{captcha.lower()}")
109109
if captcha_value is None:
110110
raise AppApiException(1005, _("Captcha code error or expiration"))
111111
username = self.data.get("username")

0 commit comments

Comments
 (0)