access tokens 0.1.1
This commit is contained in:
@@ -19,7 +19,7 @@ class UsersCrudActions:
|
||||
def get_user_by_id(self, id:UUID)->UserOutDB|None:
|
||||
with self.Session() as session:
|
||||
with session.begin():
|
||||
query=select(User).where(User.id==id)
|
||||
query=select(User).where(User.id==id)
|
||||
response=session.scalars(query).one_or_none()
|
||||
if response is None:
|
||||
return None
|
||||
|
||||
32
src/migrations/versions/23dd6d3efe4b_.py
Normal file
32
src/migrations/versions/23dd6d3efe4b_.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 23dd6d3efe4b
|
||||
Revises: 2f92088cdce4
|
||||
Create Date: 2026-07-23 13:05:12.553687
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '23dd6d3efe4b'
|
||||
down_revision: Union[str, Sequence[str], None] = '2f92088cdce4'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
@@ -27,7 +27,7 @@ class User(Model):
|
||||
|
||||
group:Mapped[list['PermissionsGroups']]=relationship(secondary="user_group", back_populates="user", lazy="selectin")
|
||||
|
||||
direct_permissions:Mapped[list['Permissions']]=relationship(secondary="user_direct_permissions", back_populates="users_direct")
|
||||
direct_permissions:Mapped[list['Permissions']]=relationship(secondary="user_direct_permissions", back_populates="users_direct", lazy="selectin")
|
||||
|
||||
refresh_token:Mapped[list['RefreshTokens']]=relationship(back_populates="user")
|
||||
report:Mapped[list["Stored"]]=relationship(back_populates="user")
|
||||
|
||||
@@ -7,6 +7,26 @@ from uuid import UUID
|
||||
class Base(BaseModel):
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class PermissionsCreate(Base):
|
||||
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||
|
||||
|
||||
class PermissionsOut(Base):
|
||||
id:Annotated[int, Field(..., description="id of the permission")]
|
||||
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||
|
||||
|
||||
class PermissionsGroupsCreate(Base):
|
||||
|
||||
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
|
||||
|
||||
|
||||
class PermissionsGroupsOut(Base):
|
||||
|
||||
id:Annotated[int, Field(..., description="id of the permission group")]
|
||||
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
|
||||
|
||||
class UserCreate(Base):
|
||||
|
||||
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
|
||||
@@ -15,8 +35,9 @@ class UserCreate(Base):
|
||||
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
|
||||
plain_password:Annotated[str, Field(...,min_length=8,max_length=72, description="plain password of the user")]
|
||||
status:Annotated[bool, Field(..., description="status of the user")]
|
||||
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||
|
||||
direct_permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||
group:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||
|
||||
class UserOut(Base):
|
||||
|
||||
@@ -25,9 +46,10 @@ class UserOut(Base):
|
||||
middle_name:Annotated[str, Field(..., max_length=64, description="middle name of the user")]
|
||||
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
|
||||
|
||||
# permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||
# permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||
direct_permissions:Annotated[list[PermissionsOut], Field(..., description="permissions of the user")]
|
||||
group:Annotated[list[PermissionsGroupsOut], Field(..., description="permissions groups of the user")]
|
||||
|
||||
|
||||
class UserOutDB(UserOut):
|
||||
id:Annotated[UUID, Field(..., description="Id of the user")]
|
||||
status:Annotated[bool, Field(..., description="status of the user")]
|
||||
@@ -40,25 +62,8 @@ class UserUpdate(Base):
|
||||
middle_name:Annotated[str|None, Field(None, max_length=64,description="middle name of the user")]
|
||||
email:Annotated[EmailStr|None, Field(None, min_length=5, max_length=255, description="email of the user")]
|
||||
status:Annotated[bool|None, Field(None, description="status of the user")]
|
||||
permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
|
||||
permission_groups:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
|
||||
|
||||
class PermissionsCreate(Base):
|
||||
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||
|
||||
|
||||
class PermissionsOut(Base):
|
||||
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||
|
||||
|
||||
class PermissionsGroupsCreate(Base):
|
||||
|
||||
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
|
||||
|
||||
|
||||
class PermissionsGroupsOut(Base):
|
||||
|
||||
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
|
||||
direct_permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
|
||||
group:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
|
||||
|
||||
|
||||
class RefreshTokensCreate(Base):
|
||||
|
||||
Reference in New Issue
Block a user