Geoapi: checkviewable permissions
This commit is contained in:
parent
76a4e8f023
commit
f04aac5667
3 changed files with 23 additions and 10 deletions
|
@ -16,6 +16,7 @@ class UserRoleLink(SQLModel, table=True):
|
|||
class UserBase(SQLModel):
|
||||
username: str
|
||||
email: str
|
||||
disabled: bool | None = False
|
||||
|
||||
|
||||
class User(UserBase, table=True):
|
||||
|
@ -25,6 +26,12 @@ class User(UserBase, table=True):
|
|||
link_model=UserRoleLink)
|
||||
password: str | None = None
|
||||
|
||||
def can_view(self, model) -> bool:
|
||||
if hasattr(model, 'viewable_role'):
|
||||
return model.viewable_role in (role.name for role in self.roles)
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
class RoleBase(SQLModel):
|
||||
name: str = Field(unique=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue