feat(usermodel): add User class
This commit is contained in:
parent
1b9dc66b08
commit
4c9151e93c
50
lumi2/usermodel.py
Normal file
50
lumi2/usermodel.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
"""Provides the application-internal class-based models for users and groups.
|
||||||
|
|
||||||
|
Also provides methods to convert LDAP user/group entries into user/group objects
|
||||||
|
and vice versa.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
class User:
|
||||||
|
"""Class model for a user.
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
----------
|
||||||
|
username : str
|
||||||
|
The user's username. Can contain only uppercase/lowercase latin characters,
|
||||||
|
numbers, hyphens, underscores and periods. Must start with a latin character.
|
||||||
|
Minimum length is 1, maximum length is 64 characters.
|
||||||
|
password_hash : str
|
||||||
|
Base64-encoded SHA512 hash of the user's password.
|
||||||
|
email : str
|
||||||
|
The user's email address.
|
||||||
|
Must contain an '@'-character, may not contain any whitespace.
|
||||||
|
first_name : str
|
||||||
|
The user's first name.
|
||||||
|
May not contain any whitespace.
|
||||||
|
last_name : str
|
||||||
|
The user's last name.
|
||||||
|
May not contain any whitespace.
|
||||||
|
display_name : str
|
||||||
|
The user's display name (as required by some LDAP-enabled applications).
|
||||||
|
May not contain any whitespace.
|
||||||
|
picture : PIL.Image
|
||||||
|
The user's profile picture as a PIL Image object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
username: str, password_hash: str, email: str,
|
||||||
|
first_name: str, last_name: str, display_name: str,
|
||||||
|
picture: Image,
|
||||||
|
):
|
||||||
|
self.username = username
|
||||||
|
self.password_hash = password_hash
|
||||||
|
self.email = email
|
||||||
|
self.first_name = first_name
|
||||||
|
self.last_name = last_name
|
||||||
|
self.display_name = display_name
|
||||||
|
self.picture = picture
|
||||||
|
|
||||||
|
# TODO validate params
|
@ -1,3 +1,4 @@
|
|||||||
Flask==2.2.2
|
Flask==2.2.2
|
||||||
ldap3==2.9.1
|
ldap3==2.9.1
|
||||||
pytest==7.2.0
|
pytest==7.2.0
|
||||||
|
Pillow==9.3.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user