mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-15 08:32:48 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2604f35bb8 | ||
|
|
6e42a9704c |
@@ -2,6 +2,7 @@ from django.utils.translation import ugettext as _
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from common.drf.serializers import BulkModelSerializer
|
from common.drf.serializers import BulkModelSerializer
|
||||||
from common.drf.serializers import MethodSerializer
|
from common.drf.serializers import MethodSerializer
|
||||||
|
from jumpserver.utils import has_valid_xpack_license
|
||||||
from ..models import LoginACL
|
from ..models import LoginACL
|
||||||
from .rules import RuleSerializer
|
from .rules import RuleSerializer
|
||||||
|
|
||||||
@@ -40,12 +41,11 @@ class LoginACLSerializer(BulkModelSerializer):
|
|||||||
self.set_action_choices()
|
self.set_action_choices()
|
||||||
|
|
||||||
def set_action_choices(self):
|
def set_action_choices(self):
|
||||||
from xpack.plugins.license.models import License
|
|
||||||
action = self.fields.get('action')
|
action = self.fields.get('action')
|
||||||
if not action:
|
if not action:
|
||||||
return
|
return
|
||||||
choices = action._choices
|
choices = action._choices
|
||||||
if not License.has_valid_license():
|
if not has_valid_xpack_license():
|
||||||
choices.pop(LoginACL.ActionChoices.confirm, None)
|
choices.pop(LoginACL.ActionChoices.confirm, None)
|
||||||
action._choices = choices
|
action._choices = choices
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ def check_different_city_login(user, request):
|
|||||||
else:
|
else:
|
||||||
city = get_ip_city(ip) or DEFAULT_CITY
|
city = get_ip_city(ip) or DEFAULT_CITY
|
||||||
|
|
||||||
last_user_login = UserLoginLog.objects.filter(username=user.username, status=True).first()
|
city_white = ['LAN', ]
|
||||||
if last_user_login and last_user_login.city != city:
|
if city not in city_white:
|
||||||
DifferentCityLoginMessage(user, ip, city).publish_async()
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user