mirror of https://github.com/jumpserver/jumpserver
parent
cabdc3ad42
commit
32a8e150da
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:523a93e9703e62c39440d2e172c96fea7d8d04965cab43095fc8a378d157bf59
|
||||
size 141798
|
||||
oid sha256:fc0862f2a9091f2e06602d6db26cfc9cc7a6b067012ec56b41ebc1e26d5072e9
|
||||
size 142045
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bd60ca8b6c43b9b5940b14a8ca8073ae26062a5402f663ac39043cbc669199bd
|
||||
size 116040
|
||||
oid sha256:1fabd2ec950291422c14b66af097bd73cce52bbc4b7913c1b9ea732eee855901
|
||||
size 116210
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,6 +16,7 @@ from rbac.permissions import RBACPermission
|
|||
from users.utils import LoginBlockUtil, MFABlockUtils
|
||||
from .mixins import UserQuerysetMixin
|
||||
from .. import serializers
|
||||
from ..exceptions import UnableToDeleteAllUsers
|
||||
from ..filters import UserFilter
|
||||
from ..models import User
|
||||
from ..notifications import ResetMFAMsg
|
||||
|
@ -55,6 +56,12 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, SuggestionMixin, BulkModelV
|
|||
queryset = super().get_queryset().prefetch_related('groups')
|
||||
return queryset
|
||||
|
||||
def allow_bulk_destroy(self, qs, filtered):
|
||||
is_valid = filtered.count() < qs.count()
|
||||
if not is_valid:
|
||||
raise UnableToDeleteAllUsers()
|
||||
return True
|
||||
|
||||
@action(methods=['get'], detail=False, url_path='suggestions')
|
||||
def match(self, request, *args, **kwargs):
|
||||
with tmp_to_root_org():
|
||||
|
@ -111,8 +118,6 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, SuggestionMixin, BulkModelV
|
|||
self.check_object_permissions(self.request, user)
|
||||
return super().perform_bulk_update(serializer)
|
||||
|
||||
def allow_bulk_destroy(self, qs, filtered):
|
||||
return filtered.count() < qs.count()
|
||||
|
||||
def perform_bulk_destroy(self, objects):
|
||||
for obj in objects:
|
||||
|
|
|
@ -15,6 +15,6 @@ class PhoneNotSet(JMSException):
|
|||
default_detail = _('Phone not set')
|
||||
|
||||
|
||||
class MFAMethodNotSupport(JMSException):
|
||||
default_code = 'mfa_not_support'
|
||||
default_detail = _('MFA method not support')
|
||||
class UnableToDeleteAllUsers(JMSException):
|
||||
default_code = 'unable_to_delete_all_users'
|
||||
default_detail = _('Unable to delete all users')
|
||||
|
|
Loading…
Reference in New Issue