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 import user as st_user
|
||||||
from scopes.storage.common import Storage
|
from scopes.storage.common import Storage
|
||||||
|
|
||||||
class User(BaseModel):
|
class UserBase(BaseModel):
|
||||||
uid: str | None = None
|
|
||||||
timeStamp: datetime | None = None
|
|
||||||
name: str
|
name: str
|
||||||
login: str
|
login: str
|
||||||
display_name: str
|
display_name: str
|
||||||
email: str | None = None
|
email: str | None = None
|
||||||
pw_hash: str | None = Field(exclude=True, default=None)
|
|
||||||
groups: List[str] = Field(default_factory=list)
|
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
|
password: str | None = None
|
||||||
|
|
||||||
def hashPassword(self) -> str | None:
|
def hashPassword(self) -> str | None:
|
||||||
|
|
|
||||||
|
|
@ -120,13 +120,15 @@ class Container:
|
||||||
changed = False
|
changed = False
|
||||||
if found.data != track.data:
|
if found.data != track.data:
|
||||||
found.update(track.data)
|
found.update(track.data)
|
||||||
|
track.data = found.data
|
||||||
changed = True
|
changed = True
|
||||||
if track.timeStamp is not None and found.timeStamp != track.timeStamp:
|
if track.timeStamp is not None and found.timeStamp != track.timeStamp:
|
||||||
found.timeStamp = track.timeStamp
|
found.timeStamp = track.timeStamp
|
||||||
changed = True
|
changed = True
|
||||||
if changed:
|
if changed:
|
||||||
self.update(found)
|
self.update(found, not track.timeStamp)
|
||||||
track.trackId = found.trackId
|
track.trackId = found.trackId
|
||||||
|
track.timeStamp = found.timeStamp
|
||||||
return found.trackId
|
return found.trackId
|
||||||
|
|
||||||
def insert(self, track, withTrackId=False):
|
def insert(self, track, withTrackId=False):
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ class User(concept.Concept):
|
||||||
def prepareData(data, obj):
|
def prepareData(data, obj):
|
||||||
data = concept.Concept.prepareData(data, obj)
|
data = concept.Concept.prepareData(data, obj)
|
||||||
pw = data.pop('password', None)
|
pw = data.pop('password', None)
|
||||||
data['pw_hash'] = obj.hashPassword()
|
if pw:
|
||||||
|
data['pw_hash'] = obj.hashPassword()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue