Skip to content
Snippets Groups Projects
Commit a76f3477 authored by Tim Repke's avatar Tim Repke
Browse files

fix mypy

parent 3368e513
No related branches found
No related tags found
1 merge request!26New auth behaviour
Pipeline #1147 passed
......@@ -199,7 +199,7 @@ async def get_assignment(assignment_id: str,
permissions=Depends(UserPermissionChecker('annotations_read'))):
assignment = await read_assignment(assignment_id=assignment_id, db_engine=db_engine)
if assignment.user_id != permissions.user.user_id:
if (assignment is None) or (assignment.user_id != permissions.user.user_id):
raise HTTPException(status_code=http_status.HTTP_401_UNAUTHORIZED,
detail='You do not have permission to handle this assignment, as it is not yours!')
......@@ -299,6 +299,9 @@ async def save_annotation(annotated_item: AnnotatedItem,
assignment_db = await read_assignment(assignment_id=annotated_item.assignment.assignment_id, db_engine=db_engine)
if assignment_db is None:
raise MissingInformationError('No assignment found!')
if permissions.user.user_id == assignment_db.user_id \
and str(assignment_db.assignment_scope_id) == annotated_item.assignment.assignment_scope_id \
and str(assignment_db.item_id) == annotated_item.assignment.item_id \
......
......@@ -34,7 +34,16 @@ async def read_users_me(current_user: UserModel = Depends(get_current_active_use
@router.get('/logout')
async def logout(current_user: UserModel = Depends(get_current_active_user)):
await auth_helper.clear_tokens_by_user(username=current_user.username)
username = current_user.username
if username is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail='RuntimeError(empty username)',
headers={'WWW-Authenticate': 'Bearer'},
)
await auth_helper.clear_tokens_by_user(username=username)
# TODO forgot password route
# TODO update user info (separate route for password updates?) /
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment