mirror of https://github.com/jumpserver/jumpserver
[Update] 修改用户更新Public_key的条件判断
parent
dbcf785e42
commit
403b6fc563
|
@ -83,8 +83,3 @@ class UserPublicKeyApi(generics.RetrieveUpdateAPIView):
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.request.user
|
return self.request.user
|
||||||
|
|
||||||
def perform_update(self, serializer):
|
|
||||||
user = self.get_object()
|
|
||||||
user.public_key = serializer.validated_data['public_key']
|
|
||||||
user.save()
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ class AuthMixin:
|
||||||
super().set_password(raw_password)
|
super().set_password(raw_password)
|
||||||
|
|
||||||
def set_public_key(self, public_key):
|
def set_public_key(self, public_key):
|
||||||
|
if self.can_update_ssh_key():
|
||||||
self.public_key = public_key
|
self.public_key = public_key
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ class AuthMixin:
|
||||||
return self.can_use_ssh_key_login()
|
return self.can_use_ssh_key_login()
|
||||||
|
|
||||||
def can_use_ssh_key_login(self):
|
def can_use_ssh_key_login(self):
|
||||||
return settings.TERMINAL_PUBLIC_KEY_AUTH
|
return self.is_local and settings.TERMINAL_PUBLIC_KEY_AUTH
|
||||||
|
|
||||||
def is_public_key_valid(self):
|
def is_public_key_valid(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue