mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
set up auth
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from dataclasses import asdict, field, dataclass
|
||||
import json
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class User:
|
||||
id: int
|
||||
username: str
|
||||
firstname: str
|
||||
lastname: str
|
||||
password: str
|
||||
email: str
|
||||
image: str
|
||||
|
||||
# NOTE: roles: ['admin', 'user', 'curator']
|
||||
roles: list[str] = field(default_factory=lambda: ["user"])
|
||||
|
||||
def __post_init__(self):
|
||||
self.roles = json.loads(self.roles)
|
||||
|
||||
def todict(self):
|
||||
this_dict = asdict(self)
|
||||
del this_dict["password"]
|
||||
|
||||
return this_dict
|
||||
|
||||
def todict_simplified(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"username": self.username,
|
||||
"firstname": self.firstname,
|
||||
}
|
||||
Reference in New Issue
Block a user