From 947f16e3710e1131fabec5ef8591049311f2ad7b Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Fri, 26 Jul 2019 10:46:43 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E6=98=AF=E5=90=A6=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9B=B4=E6=94=B9/=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AF=86=E9=92=A5=E7=99=BB=E5=BD=95=EF=BC=8C=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?settings=E9=85=8D=E7=BD=AE=E8=BF=9B=E8=A1=8C=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/models/user.py | 5 ++++- apps/users/utils.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/users/models/user.py b/apps/users/models/user.py index f6c083c56..23587b1f1 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -55,7 +55,10 @@ class AuthMixin: return self.is_local def can_update_ssh_key(self): - return self.is_local + return self.can_use_ssh_key_login() + + def can_use_ssh_key_login(self): + return settings.TERMINAL_PUBLIC_KEY_AUTH def check_otp(self, code): from ..utils import check_otp_code diff --git a/apps/users/utils.py b/apps/users/utils.py index 662ddedec..88564c2d3 100644 --- a/apps/users/utils.py +++ b/apps/users/utils.py @@ -198,7 +198,7 @@ def check_user_valid(**kwargs): if password and authenticate(username=username, password=password): return user, '' - if public_key and user.public_key and user.is_local: + if public_key and user.public_key and user.can_use_ssh_key_login(): public_key_saved = user.public_key.split() if len(public_key_saved) == 1: if public_key == public_key_saved[0]: