Skip to content

Commit

Permalink
revert annotator object change (unncessary Pydantic annotation was br…
Browse files Browse the repository at this point in the history
…eaking things
  • Loading branch information
ToucheSir committed Apr 22, 2021
1 parent 38064b3 commit e0f92cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 1 addition & 9 deletions backend/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,7 @@ async def add_user(
db: DatabaseContext = Depends(get_db),
):
encrypted = bcrypt.hash(password)
await db.add_user(
Annotator(
_id=ObjectId(),
name=name,
username=username,
designation=designation,
hashed_password=encrypted,
)
)
await db.add_user(name, username, designation, encrypted)
return "A new user has been added"


Expand Down
11 changes: 9 additions & 2 deletions backend/app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ async def reset_password(self, username: str, hashed_password: str):
{"username": username}, {"$set": {"hashed_password": hashed_password}}
)

async def add_user(self, user: Annotator):
return await self.annotators.insert_one(user.dict())
async def add_user(self, name: str, username: str, designation: str, password: str):
return await self.annotators.insert_one({
"name": name,
"username": username,
"designation": designation,
"hashed_password": password,
"current_campaign": None,
"previous_campaigns": []
})

async def get_annotator(self, username: str) -> Optional[Annotator]:
res = await self.annotators.find_one({"username": username})
Expand Down

0 comments on commit e0f92cc

Please sign in to comment.