Skip to content

Commit

Permalink
Fixed: can now approve documents created by others (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Aug 27, 2024
1 parent d16f94a commit cc3249a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libreforms_fastapi/utils/document_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,12 @@ def sign_document(
self.logger.warning(f"Document for {form_name} with document_id {document_id} is deleted and was not updated")
raise DocumentIsDeleted(form_name, document_id)

if username != document['metadata'][self.created_by_field]:
if self.use_logger:
self.logger.warning(f"Insufficient permissions to {'unsign' if unsign else 'sign'} document for {form_name} with document_id {document_id}")
raise InsufficientPermissions(form_name, document_id, username)
# Deprecated following changed assumptions about who will be able to sign documents. Previous assumption
# was that only creators sign documents... since, we've moved to a broader conception of the signing operation.
# if username != document['metadata'][self.created_by_field]:
# if self.use_logger:
# self.logger.warning(f"Insufficient permissions to {'unsign' if unsign else 'sign'} document for {form_name} with document_id {document_id}")
# raise InsufficientPermissions(form_name, document_id, username)

# If we are trying to unsign the document, then we remove the signature, update the document, and return.
if unsign:
Expand Down

0 comments on commit cc3249a

Please sign in to comment.