Merge pull request #7107 from jumpserver/dev

v2.15.0
pull/7119/head v2.15.1
Jiangjie.Bai 2021-10-28 17:45:42 +08:00 committed by GitHub
commit 15cdd44c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -76,12 +76,12 @@ class Migration(migrations.Migration):
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='login_acls', to=settings.AUTH_USER_MODEL, verbose_name='User'),
),
migrations.RunPython(migrate_login_confirm),
migrations.AddField(
model_name='loginacl',
name='rules',
field=models.JSONField(default=dict, verbose_name='Rule'),
),
migrations.RunPython(migrate_login_confirm),
migrations.RunPython(migrate_ip_group),
migrations.RemoveField(
model_name='loginacl',

View File

@ -35,6 +35,20 @@ class LoginACLSerializer(BulkModelSerializer):
"reviewers": {'allow_null': False, 'required': True},
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
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():
choices.pop(LoginACL.ActionChoices.confirm, None)
action._choices = choices
def get_rules_serializer(self):
return RuleSerializer()