storage: fix tracking update logic; api.auth.user: split model (view) classes
This commit is contained in:
parent
1709290ea9
commit
2c43df83a5
3 changed files with 12 additions and 7 deletions
|
|
@ -12,17 +12,19 @@ from scopes.config import settings
|
|||
from scopes.storage import user as st_user
|
||||
from scopes.storage.common import Storage
|
||||
|
||||
class User(BaseModel):
|
||||
uid: str | None = None
|
||||
timeStamp: datetime | None = None
|
||||
class UserBase(BaseModel):
|
||||
name: str
|
||||
login: str
|
||||
display_name: str
|
||||
email: str | None = None
|
||||
pw_hash: str | None = Field(exclude=True, default=None)
|
||||
groups: List[str] = Field(default_factory=list)
|
||||
|
||||
class UserIn(User):
|
||||
class User(UserBase):
|
||||
uid: str | None = None
|
||||
timeStamp: datetime | None = None
|
||||
pw_hash: str | None = Field(exclude=True, default=None)
|
||||
|
||||
class UserIn(UserBase):
|
||||
password: str | None = None
|
||||
|
||||
def hashPassword(self) -> str | None:
|
||||
|
|
|
|||
|
|
@ -120,13 +120,15 @@ class Container:
|
|||
changed = False
|
||||
if found.data != track.data:
|
||||
found.update(track.data)
|
||||
track.data = found.data
|
||||
changed = True
|
||||
if track.timeStamp is not None and found.timeStamp != track.timeStamp:
|
||||
found.timeStamp = track.timeStamp
|
||||
changed = True
|
||||
if changed:
|
||||
self.update(found)
|
||||
self.update(found, not track.timeStamp)
|
||||
track.trackId = found.trackId
|
||||
track.timeStamp = found.timeStamp
|
||||
return found.trackId
|
||||
|
||||
def insert(self, track, withTrackId=False):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class User(concept.Concept):
|
|||
def prepareData(data, obj):
|
||||
data = concept.Concept.prepareData(data, obj)
|
||||
pw = data.pop('password', None)
|
||||
if pw:
|
||||
data['pw_hash'] = obj.hashPassword()
|
||||
return data
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue