[Update] 修改用户更新Public_key的条件判断

pull/4082/head
Bai 2020-06-04 17:02:43 +08:00
parent dbcf785e42
commit 403b6fc563
2 changed files with 4 additions and 8 deletions

View File

@ -83,8 +83,3 @@ class UserPublicKeyApi(generics.RetrieveUpdateAPIView):
def get_object(self):
return self.request.user
def perform_update(self, serializer):
user = self.get_object()
user.public_key = serializer.validated_data['public_key']
user.save()

View File

@ -48,8 +48,9 @@ class AuthMixin:
super().set_password(raw_password)
def set_public_key(self, public_key):
self.public_key = public_key
self.save()
if self.can_update_ssh_key():
self.public_key = public_key
self.save()
def can_update_password(self):
return self.is_local
@ -58,7 +59,7 @@ class AuthMixin:
return self.can_use_ssh_key_login()
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):
"""