summaryrefslogtreecommitdiffstats
path: root/accounts/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/models.py')
-rw-r--r--accounts/models.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/accounts/models.py b/accounts/models.py
index 7bbb235..8b34fab 100644
--- a/accounts/models.py
+++ b/accounts/models.py
@@ -19,7 +19,7 @@ class Service(object):
self.changed = False
def __repr__(self):
- return '<Service %s>' % self.id
+ return "<Service %s>" % self.id
class Account(UserMixin):
@@ -27,6 +27,7 @@ class Account(UserMixin):
An Account represents a complex ldap tree entry for spline users.
For each service a spline user can have a different password.
"""
+
_ready = False
uid: str
@@ -36,8 +37,14 @@ class Account(UserMixin):
attributes: dict[Any, Any]
new_password_root: Optional[tuple[Optional[str], Optional[str]]]
- def __init__(self, uid: str, mail: str, services=None,
- password: Optional[str] = None, uidNumber=None):
+ def __init__(
+ self,
+ uid: str,
+ mail: str,
+ services=None,
+ password: Optional[str] = None,
+ uidNumber=None,
+ ):
self.uid = uid
self.services = list() if services is None else services
self.password = password
@@ -46,7 +53,7 @@ class Account(UserMixin):
self.attributes = {}
self.uidNumber = uidNumber
- self._set_attribute('mail', mail)
+ self._set_attribute("mail", mail)
self._ready = True
def __repr__(self):
@@ -55,8 +62,9 @@ class Account(UserMixin):
def reset_password(self, service: str):
self.new_password_services[service] = (None, None)
- def change_password(self, new_password: str, old_password='',
- service=None):
+ def change_password(
+ self, new_password: str, old_password="", service=None
+ ):
"""
Changes a password for a given service. You have to use the
UserBackend to make the changes permanent. If no service is given,
@@ -76,14 +84,16 @@ class Account(UserMixin):
Changes the mail address of an account. You have to use the
AccountService class to make changes permanent.
"""
- self._set_attribute('mail', new_mail)
+ self._set_attribute("mail", new_mail)
def __getattr__(self, name):
if name in self.attributes:
return self.attributes[name]
- raise AttributeError("'%s' object has no attribute '%s'" %
- (self.__class__.__name__, name))
+ raise AttributeError(
+ "'%s' object has no attribute '%s'"
+ % (self.__class__.__name__, name)
+ )
def __setattr__(self, name: str, value: Any):
if self._ready and name not in self.__dict__: