forked from Github-Mirrors/canaille
refactor: User.has_password factorization
This commit is contained in:
parent
e317780e1d
commit
e339d1169d
5 changed files with 1 additions and 13 deletions
|
@ -65,9 +65,6 @@ class User(canaille.core.models.User, LDAPObject):
|
|||
def identifier(self):
|
||||
return self.rdn_value
|
||||
|
||||
def has_password(self):
|
||||
return bool(self.password)
|
||||
|
||||
def check_password(self, password):
|
||||
conn = ldap.initialize(current_app.config["CANAILLE_LDAP"]["URI"])
|
||||
|
||||
|
|
|
@ -250,9 +250,6 @@ class User(canaille.core.models.User, MemoryModel):
|
|||
def get_from_login(cls, login=None, **kwargs):
|
||||
return User.get(user_name=login)
|
||||
|
||||
def has_password(self):
|
||||
return bool(self.password)
|
||||
|
||||
def check_password(self, password):
|
||||
if password != self.password:
|
||||
return (False, None)
|
||||
|
|
|
@ -175,9 +175,6 @@ class User(canaille.core.models.User, Base, SqlAlchemyModel):
|
|||
def get_from_login(cls, login=None, **kwargs):
|
||||
return User.get(user_name=login)
|
||||
|
||||
def has_password(self):
|
||||
return self.password is not None
|
||||
|
||||
def check_password(self, password):
|
||||
if password != self.password:
|
||||
return (False, None)
|
||||
|
|
|
@ -250,7 +250,7 @@ class User(Model):
|
|||
|
||||
def has_password(self) -> bool:
|
||||
"""Checks wether a password has been set for the user."""
|
||||
raise NotImplementedError()
|
||||
return self.password is not None
|
||||
|
||||
def check_password(self, password: str) -> bool:
|
||||
"""Checks if the password matches the user password in the database."""
|
||||
|
|
|
@ -11,9 +11,6 @@ def test_required_methods(testclient):
|
|||
|
||||
user = User()
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
user.has_password()
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
user.check_password("password")
|
||||
|
||||
|
|
Loading…
Reference in a new issue