Skip to content

Commit

Permalink
do not return superuser
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Karamanis committed Dec 3, 2024
1 parent a4de9d8 commit 79fcf52
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions neu_users/routes/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
from neu_sdk.config import LOGGER
from neu_sdk.security import check_password

from neu_users.schemas import User, UserCreate, UserPasswordUpdate, UserPublic, UserPublicRestricted, UserUpdate
from neu_users.schemas import (
User,
UserCreate,
UserPasswordUpdate,
UserPublic,
UserPublicRestricted,
UserUpdate,
)

router = APIRouter(tags=["users"], responses={404: {"description": "Not found"}})


@router.post("/", response_model=UserPublic)
async def create_user(data: UserCreate) -> UserPublic:
try:
await User.find((User.username == data.username) | (User.email == data.email)).first()
await User.find(
(User.username == data.username) | (User.email == data.email)
).first()
raise HTTPException(403, "User already exists")
except NotFoundError as e:
pass
Expand All @@ -37,7 +46,7 @@ async def get_users(
offset: int = Query(0),
limit: int = Query(100),
) -> list[UserPublicRestricted]:
expression = []
expression = [(User.superuser == False)]

if name:
expression += [(User.first_name % f"*{name}*") | (User.last_name % f"*{name}*")]
Expand Down

0 comments on commit 79fcf52

Please sign in to comment.