Commit 5d800fa6 authored by BaiJiangJie's avatar BaiJiangJie

[Update] 修改coco端登录限制次数逻辑

parent bd14266a
...@@ -199,17 +199,16 @@ class UserAuthApi(APIView): ...@@ -199,17 +199,16 @@ class UserAuthApi(APIView):
key_prefix_limit = "_LOGIN_LIMIT_{}_{}" key_prefix_limit = "_LOGIN_LIMIT_{}_{}"
def post(self, request): def post(self, request):
user, msg = self.check_user_valid(request) # limit login
username = request.data.get('username') username = request.data.get('username')
ip = request.data.get('remote_addr', None) ip = request.data.get('remote_addr', None)
if not ip: ip = ip if ip else get_login_ip(request)
ip = get_login_ip(request)
key_limit = self.key_prefix_limit.format(ip, username) key_limit = self.key_prefix_limit.format(ip, username)
if is_block_login(key_limit): if is_block_login(key_limit):
msg = _("Log in frequently and try again later") msg = _("Log in frequently and try again later")
return Response({'msg': msg}, status=401) return Response({'msg': msg}, status=401)
user, msg = self.check_user_valid(request)
if not user: if not user:
data = { data = {
'username': request.data.get('username', ''), 'username': request.data.get('username', ''),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment