05/18 Enhanced codes and functionalities 4
This commit is contained in:
+11
-6
@@ -123,6 +123,9 @@ def create_share():
|
||||
iv = data.get('iv', '')
|
||||
item_name = (data.get('item_name') or '').strip()
|
||||
item_type = data.get('item_type', 'password')
|
||||
# Encrypted display name — encrypted with the ECDH shared secret client-side.
|
||||
enc_name = data.get('enc_name') or None
|
||||
iv_name = data.get('iv_name') or None
|
||||
|
||||
if not all([item_id, recipient_email, enc_data, iv, item_name]):
|
||||
return jsonify({'error': 'item_id, recipient_email, enc_data, iv, item_name are required'}), 400
|
||||
@@ -144,10 +147,12 @@ def create_share():
|
||||
owner_id=g.current_user_id,
|
||||
recipient_email=recipient_email,
|
||||
recipient_id=recipient.id if recipient else None,
|
||||
item_name=item_name,
|
||||
item_name=item_name, # non-sensitive label (item_type value)
|
||||
item_type=item_type,
|
||||
enc_data=enc_data,
|
||||
iv=iv,
|
||||
enc_name=enc_name,
|
||||
iv_name=iv_name,
|
||||
)
|
||||
db.session.add(share)
|
||||
db.session.flush() # populate share.id before logging
|
||||
@@ -157,7 +162,7 @@ def create_share():
|
||||
action='shared_item.create',
|
||||
resource_type='shared_item',
|
||||
resource_id=share.id,
|
||||
detail=f'Shared item "{item_name}" ({item_type}) with {recipient_email}',
|
||||
detail=f'Shared {item_type} item (id={item_id}) with {recipient_email}',
|
||||
ip_address=client_ip(),
|
||||
)
|
||||
db.session.commit()
|
||||
@@ -173,8 +178,8 @@ def delete_share(share_id):
|
||||
if not share:
|
||||
return jsonify({'error': 'Share not found'}), 404
|
||||
|
||||
item_name = share.item_name
|
||||
recipient_email = share.recipient_email
|
||||
item_type_saved = share.item_type
|
||||
recipient_email_saved = share.recipient_email
|
||||
db.session.delete(share)
|
||||
db.session.flush()
|
||||
|
||||
@@ -183,7 +188,7 @@ def delete_share(share_id):
|
||||
action='shared_item.delete',
|
||||
resource_type='shared_item',
|
||||
resource_id=share_id,
|
||||
detail=f'Revoked share of "{item_name}" with {recipient_email}',
|
||||
detail=f'Revoked share of {item_type_saved} item (share_id={share_id}) with {recipient_email_saved}',
|
||||
ip_address=client_ip(),
|
||||
)
|
||||
db.session.commit()
|
||||
@@ -247,7 +252,7 @@ def accept_share(share_id):
|
||||
action='shared_item.accept',
|
||||
resource_type='shared_item',
|
||||
resource_id=share.id,
|
||||
detail=f'Accepted shared item "{share.item_name}" from {owner_email}',
|
||||
detail=f'Accepted shared {share.item_type} item (share_id={share.id}) from {owner_email}',
|
||||
ip_address=client_ip(),
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user