提交 403b6fc5 编写于 作者: B Bai

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

上级 dbcf785e
......@@ -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()
......@@ -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):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册