mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-03 00:15:20 +00:00
fix: 修复暴力校验验证码
This commit is contained in:
@@ -26,6 +26,7 @@ class SendAndVerifyCodeUtil(object):
|
|||||||
self.target = target
|
self.target = target
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.key = key or self.KEY_TMPL.format(target)
|
self.key = key or self.KEY_TMPL.format(target)
|
||||||
|
self.verify_key = self.key + '_verify'
|
||||||
self.timeout = settings.VERIFY_CODE_TTL if timeout is None else timeout
|
self.timeout = settings.VERIFY_CODE_TTL if timeout is None else timeout
|
||||||
self.other_args = kwargs
|
self.other_args = kwargs
|
||||||
|
|
||||||
@@ -47,6 +48,11 @@ class SendAndVerifyCodeUtil(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def verify(self, code):
|
def verify(self, code):
|
||||||
|
times = cache.get(self.verify_key, 0)
|
||||||
|
if times >= 3:
|
||||||
|
self.__clear()
|
||||||
|
raise CodeError
|
||||||
|
cache.set(self.verify_key, times + 1, timeout=self.timeout)
|
||||||
right = cache.get(self.key)
|
right = cache.get(self.key)
|
||||||
if not right:
|
if not right:
|
||||||
raise CodeExpired
|
raise CodeExpired
|
||||||
|
Reference in New Issue
Block a user