add secret to User & add user REST routes

This commit is contained in:
ducklet 2021-08-04 17:31:59 +02:00
parent 9bb433eb0c
commit f7913c30c8
4 changed files with 118 additions and 3 deletions

View file

@ -69,12 +69,15 @@ def optional_fields(o):
yield f
def asplain(o) -> dict[str, Any]:
def asplain(o, *, fields_: set = None) -> dict[str, Any]:
validate(o)
d = {}
for f in fields(o):
if fields_ is not None and f.name not in fields_:
continue
target = f.type
# XXX this doesn't properly support any kind of nested types
if (otype := optional_type(f.type)) is not None:
@ -278,6 +281,7 @@ class User:
id: ULID = field(default_factory=ULID)
imdb_id: str = None
name: str = None # canonical user name
secret: str = None
@dataclass