[Update] 禁用其他认证方式修改密码 (#2286)

* [Update] 禁用其他认证方式修改密码

* [Update] 禁用其他认证方式修改密码

* [Update] 禁用其他认证方式修改密码
This commit is contained in:
老广
2018-12-27 16:47:40 +08:00
committed by GitHub
parent b55d137e7f
commit 560df5027a
8 changed files with 156 additions and 116 deletions

View File

@@ -120,7 +120,14 @@ class User(AbstractUser):
def set_password(self, raw_password):
self._set_password = True
return super().set_password(raw_password)
if self.can_update_password():
return super().set_password(raw_password)
else:
error = _("User auth from {}, go there change password").format(self.source)
raise PermissionError(error)
def can_update_password(self):
return self.is_local
@property
def otp_secret_key(self):