From 9b14244363ee6f9f4e293ed7cf811196d20a1df7 Mon Sep 17 00:00:00 2001 From: njqaaa Date: Tue, 6 Jun 2017 11:23:39 +0800 Subject: [PATCH] fix id_dsa check error (#458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix id_dsa check error * fix 邮件修改密码 token错误 * fix 3c8aec9 add ) --- apps/common/utils.py | 7 +++---- apps/users/models/user.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/common/utils.py b/apps/common/utils.py index 1fb7c77f5..003c1f5b5 100644 --- a/apps/common/utils.py +++ b/apps/common/utils.py @@ -180,15 +180,14 @@ def timesince(dt, since='', default="just now"): def ssh_key_string_to_obj(text): - key_f = StringIO(text) key = None try: - key = paramiko.RSAKey.from_private_key(key_f) + key = paramiko.RSAKey.from_private_key( StringIO(text) ) except paramiko.SSHException: pass try: - key = paramiko.DSSKey.from_private_key(key_f) + key = paramiko.DSSKey.from_private_key( StringIO(text) ) except paramiko.SSHException: pass return key @@ -375,4 +374,4 @@ def sum_capacity(cap_list): return capacity_convert(total, expect='auto') -signer = Signer() \ No newline at end of file +signer = Signer() diff --git a/apps/users/models/user.py b/apps/users/models/user.py index 0aaa8163f..2772558d8 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -189,7 +189,7 @@ class User(AbstractUser): return 'https://www.gravatar.com/avatar/c6812ab450230979465d7bf288eadce2a?s=120&d=identicon' def generate_reset_token(self): - return signer.sign_t({'reset': self.id, 'email': self.email}, expires_in=3600) + return signer.sign_t({'reset': self.id, 'email': self.email}, expires_in=3600).decode('utf-8') def to_json(self): return OrderedDict({