[Update] 添加用户profile public-key序列类

This commit is contained in:
Bai
2020-05-28 17:47:18 +08:00
parent 3e5d949610
commit 3b8a24eeb7
2 changed files with 42 additions and 13 deletions

View File

@@ -47,6 +47,10 @@ class AuthMixin:
post_user_change_password.send(self.__class__, user=self)
super().set_password(raw_password)
def set_public_key(self, public_key):
self.public_key = public_key
self.save()
def can_update_password(self):
return self.is_local
@@ -79,6 +83,14 @@ class AuthMixin:
pass
return PubKey()
def get_public_key_comment(self):
return self.public_key_obj.comment
def get_public_key_hash_md5(self):
if not callable(self.public_key_obj.hash_md5):
return ''
return self.public_key_obj.hash_md5()
def reset_password(self, new_password):
self.set_password(new_password)
self.save()