summaryrefslogtreecommitdiffstats
path: root/accounts/backend/user/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/backend/user/__init__.py')
-rw-r--r--accounts/backend/user/__init__.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/accounts/backend/user/__init__.py b/accounts/backend/user/__init__.py
index e72302a..1504e41 100644
--- a/accounts/backend/user/__init__.py
+++ b/accounts/backend/user/__init__.py
@@ -1,5 +1,8 @@
# -*- coding: utf-8 -*-
+from accounts.app import AccountsFlask
+from accounts.models import Account
+
class NoSuchUserError(ValueError):
pass
@@ -49,7 +52,9 @@ class Backend(object):
>> backend.find_by_uid('test*', wildcard=True) # find with wildcards
"""
- def __init__(self, app):
+ app: AccountsFlask
+
+ def __init__(self, app: AccountsFlask) -> None:
self.app = app
#: Exception type, that is raised if no matching user was found.
@@ -60,14 +65,14 @@ class Backend(object):
#: could also be raised, if you want to change user information.
self.InvalidPasswordError = InvalidPasswordError
- def auth(self, username, password):
+ def auth(self, username: str, password: str):
"""
Tries to authenticate a user with a given password. If the
authentication is successful an Account object will be returned.
"""
raise NotImplementedError()
- def get_by_uid(self, uid):
+ def get_by_uid(self, uid: str) -> Account:
"""
Find a single user by uid. Unlike find_by_uid, don't return a list but
raise NoSuchUserError if there is no such user.
@@ -80,7 +85,7 @@ class Backend(object):
return users[0]
- def get_by_mail(self, mail):
+ def get_by_mail(self, mail: str) -> Account:
"""
Find a single user by mail. Unlike find_by_mail, don't return a list but
raise NoSuchUserError if there is no such user.
@@ -93,19 +98,19 @@ class Backend(object):
return users[0]
- def find_by_uid(self, uid, wildcard=False):
+ def find_by_uid(self, uid: str, wildcard=False) -> list[Account]:
return self.find({'uid': uid}, wildcard)
- def find_by_mail(self, mail, wildcard=False):
+ def find_by_mail(self, mail: str, wildcard=False) -> list[Account]:
return self.find({'mail': mail}, wildcard)
- def find(self, filters=None, wildcard=False):
+ def find(self, filters=None, wildcard=False) -> list[Account]:
"""
Find accounts by a given filter.
"""
raise NotImplementedError()
- def register(self, account):
+ def register(self, account: Account):
"""
Register a new user account.
@@ -118,7 +123,7 @@ class Backend(object):
account.uidNumber = self._get_next_uidNumber()
self._store(account)
- def update(self, account, as_admin=False):
+ def update(self, account: Account, as_admin=False):
"""
Updates account information like passwords or email.
"""