mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-15 08:32:48 +00:00
Compare commits
3 Commits
pr@dev@ter
...
v2.15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79600e25f1 | ||
|
|
2604f35bb8 | ||
|
|
6e42a9704c |
@@ -2,6 +2,7 @@ from django.utils.translation import ugettext as _
|
||||
from rest_framework import serializers
|
||||
from common.drf.serializers import BulkModelSerializer
|
||||
from common.drf.serializers import MethodSerializer
|
||||
from jumpserver.utils import has_valid_xpack_license
|
||||
from ..models import LoginACL
|
||||
from .rules import RuleSerializer
|
||||
|
||||
@@ -40,12 +41,11 @@ class LoginACLSerializer(BulkModelSerializer):
|
||||
self.set_action_choices()
|
||||
|
||||
def set_action_choices(self):
|
||||
from xpack.plugins.license.models import License
|
||||
action = self.fields.get('action')
|
||||
if not action:
|
||||
return
|
||||
choices = action._choices
|
||||
if not License.has_valid_license():
|
||||
if not has_valid_xpack_license():
|
||||
choices.pop(LoginACL.ActionChoices.confirm, None)
|
||||
action._choices = choices
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ def check_different_city_login(user, request):
|
||||
else:
|
||||
city = get_ip_city(ip) or DEFAULT_CITY
|
||||
|
||||
last_user_login = UserLoginLog.objects.filter(username=user.username, status=True).first()
|
||||
if last_user_login and last_user_login.city != city:
|
||||
DifferentCityLoginMessage(user, ip, city).publish_async()
|
||||
city_white = ['LAN', ]
|
||||
if city not in city_white:
|
||||
last_user_login = UserLoginLog.objects.exclude(city__in=city_white) \
|
||||
.filter(username=user.username, status=True).first()
|
||||
|
||||
if last_user_login and last_user_login.city != city:
|
||||
DifferentCityLoginMessage(user, ip, city).publish_async()
|
||||
|
||||
@@ -2,6 +2,7 @@ import threading
|
||||
import json
|
||||
from redis.exceptions import ConnectionError
|
||||
from channels.generic.websocket import JsonWebsocketConsumer
|
||||
from django.db import close_old_connections
|
||||
|
||||
from common.utils import get_logger
|
||||
from .site_msg import SiteMessageUtil
|
||||
@@ -65,8 +66,11 @@ class SiteMsgWebsocket(JsonWebsocketConsumer):
|
||||
logger.debug('Decode json error: ', e)
|
||||
except ConnectionError:
|
||||
logger.debug('Redis chan closed')
|
||||
finally:
|
||||
close_old_connections()
|
||||
|
||||
def disconnect(self, close_code):
|
||||
if self.chan is not None:
|
||||
self.chan.close()
|
||||
self.close()
|
||||
close_old_connections()
|
||||
|
||||
Reference in New Issue
Block a user