Skip to content

Commit

Permalink
Change domain for user. Add booleans to new_user created.
Browse files Browse the repository at this point in the history
  • Loading branch information
danilojezernik committed Jun 27, 2024
1 parent 2018fa7 commit 08ca8a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/domain/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class User(BaseModel):
username: str
email: str
full_name: str
profession: Optional[str] = None
technology: Optional[str] = None
description: Optional[str] = None
profession: Optional[str] = ''
technology: Optional[str] = ''
description: str
hashed_password: str
confirmed: bool
registered: Optional[bool]
registered: bool
blog_notification: bool
datum_vnosa: datetime.datetime = Field(default_factory=datetime.datetime.now)
6 changes: 6 additions & 0 deletions src/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ async def add_new_user(user_data: User, current_user: str = Depends(get_current_
- Returns the added User object if successful, or None if unsuccessful.
"""

print(user_data)

# Hash the user's password for security
hashed_password = make_hash(user_data.hashed_password)

Expand All @@ -111,12 +113,16 @@ async def add_new_user(user_data: User, current_user: str = Depends(get_current_
email=user_data.email,
full_name=user_data.full_name,
hashed_password=hashed_password,
description=user_data.description,
profession=user_data.profession,
technology=user_data.technology,
disabled=False, # Set the user as enabled by default
confirmed=user_data.confirmed,
registered=user_data.registered,
blog_notification=user_data.blog_notification,
).dict(by_alias=True)

print(new_user)
# Insert the new user into the database
insert_user = db.process.user.insert_one(new_user)

Expand Down

0 comments on commit 08ca8a1

Please sign in to comment.