05/18 Enhanced codes and functionalities 10
This commit is contained in:
@@ -62,4 +62,29 @@ class EmergencyAccess(db.Model):
|
||||
self.request_initiated_at.isoformat() if self.request_initiated_at else None
|
||||
),
|
||||
'created_at': self.created_at.isoformat() if self.created_at else None,
|
||||
# True when enc_vault contains items in the old format (has a plaintext
|
||||
# 'name' field instead of enc_name/iv_name). Grantor should re-provision.
|
||||
'enc_vault_is_legacy': self._enc_vault_is_legacy(),
|
||||
}
|
||||
|
||||
def _enc_vault_is_legacy(self) -> bool:
|
||||
"""
|
||||
Return True if the stored enc_vault snapshot was created before the
|
||||
enc_name migration — i.e. any item has a 'name' key (plaintext) but
|
||||
lacks 'enc_name'. Returns False if no snapshot exists or all items
|
||||
use the new format.
|
||||
"""
|
||||
if not self.enc_vault:
|
||||
return False
|
||||
try:
|
||||
import json
|
||||
items = json.loads(self.enc_vault)
|
||||
if not isinstance(items, list):
|
||||
return False
|
||||
# Old format: item has 'name' and no 'enc_name'
|
||||
return any(
|
||||
isinstance(item, dict) and 'name' in item and 'enc_name' not in item
|
||||
for item in items
|
||||
)
|
||||
except (ValueError, TypeError):
|
||||
return False
|
||||
@@ -1816,6 +1816,16 @@ const Vault = (() => {
|
||||
if (g.status === "accepted") {
|
||||
actions = `<button class="btn-primary btn-sm" data-provide="${g.id}">Provide Recovery Data</button>`;
|
||||
}
|
||||
if (g.status === "ready") {
|
||||
// Check if the stored snapshot is in the old format (plaintext names).
|
||||
if (g.enc_vault_is_legacy) {
|
||||
actions = `
|
||||
<span class="badge badge-warn" title="Recovery snapshot contains plaintext item names. Re-provision to encrypt them.">⚠ Outdated snapshot</span>
|
||||
<button class="btn-primary btn-sm" data-provide="${g.id}">Re-provision</button>`;
|
||||
} else {
|
||||
actions = `<button class="btn-secondary btn-sm" data-provide="${g.id}">Update Recovery Data</button>`;
|
||||
}
|
||||
}
|
||||
if (g.status === "pending") {
|
||||
const waitInfo = g.wait_elapsed
|
||||
? "Wait period elapsed"
|
||||
|
||||
Reference in New Issue
Block a user