diff --git a/apps/users/models/user.py b/apps/users/models/user.py index f6c083c562c537c26d5f598d3427a40b20460082..23587b1f1b8370d327a697430b99b84cd29fd2e8 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 662ddedec81589627f636a6b018ce2e9e3201f5a..88564c2d306395244d072d7a5b6e753c7ece80d9 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]: