You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the function that allow you to update the user doesn't check if the new username already exist, this could cause authentication issue as the username is used to differentiates between user.
My solutions :
# UPDATE User profile@router.put('/{username}/update', response_model=User)asyncdefupdate_user(attributes: dict, username: str):
# Add check to stop call if password is being changedforkinattributes:
ifk=='hashed_password':
raiseHTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Operation not permitted, cannot update password with this method.",
headers={"WWW-Authenticate": "Bearer"})
ifk=='username':
#print(f"\n update \n {username}\n-\n{attributes['username']}\n-\n")query='MATCH (user:User) WHERE user.username = $username RETURN user'name=attributes['username']
withneo4j_driver.session() assession:
user_in_db=session.run(query=query, parameters={'username': name})
data=user_in_db.data()
#print(f"data {data}\n")ifdata:
raiseHTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Username already exists.",
headers={"WWW-user-delete": "Bearer"})
ifattributes:
unpacked_attributes='SET '+', '.join(f'user.{key}=\'{value}\''for (key, value) inattributes.items())
else:
unpacked_attributes=''# Execute Cypher query to update the user attributescypher_update_user= ('MATCH (user: User) WHERE user.username = $user\n'f'{unpacked_attributes}\n''RETURN user')
withneo4j_driver.session() assession:
updated_user=session.run(query=cypher_update_user,
parameters={'user': username})
user_data=updated_user.data()[0]['user']
returnUser(**user_data)
The text was updated successfully, but these errors were encountered:
Currently the function that allow you to update the user doesn't check if the new username already exist, this could cause authentication issue as the username is used to differentiates between user.
My solutions :
The text was updated successfully, but these errors were encountered: