diff --git a/lnbits/core/templates/audit/index.html b/lnbits/core/templates/audit/index.html
index 4d3d3cee5..9c68a65f9 100644
--- a/lnbits/core/templates/audit/index.html
+++ b/lnbits/core/templates/audit/index.html
@@ -48,7 +48,7 @@
size="sm"
flat
class="cursor-pointer q-mr-xs"
- @click="copyText(props.row[col.name])"
+ @click="showDetailsDialog(props.row)"
>
Request Details
@@ -87,6 +87,36 @@
+
+
+ HTTP Request Details
+
+
+
+
+
+
+
+
+
{% endblock %} {% block scripts %} {{ window_vars(user) }}
{% endblock %}
diff --git a/lnbits/middleware.py b/lnbits/middleware.py
index b357e486d..eeca79cfd 100644
--- a/lnbits/middleware.py
+++ b/lnbits/middleware.py
@@ -165,9 +165,12 @@ class AuditMiddleware(BaseHTTPMiddleware):
if settings.lnbits_audit_log_ip_address and request.client
else None
)
+ user_id = request.scope.get("user_id", None)
+ if settings.is_super_user(user_id):
+ user_id = "super_user"
data = AuditEntry(
ip_address=ip_address,
- user_id=request.scope.get("user_id", None),
+ user_id=user_id,
path=getattr(request.scope.get("route", {}), "path", None),
request_type=request.scope.get("type", None),
request_method=http_method,
diff --git a/lnbits/settings.py b/lnbits/settings.py
index d7efb5b8b..592c750ab 100644
--- a/lnbits/settings.py
+++ b/lnbits/settings.py
@@ -764,7 +764,7 @@ class Settings(EditableSettings, ReadOnlySettings, TransientSettings, BaseSettin
or user_id == self.super_user
)
- def is_super_user(self, user_id: str) -> bool:
+ def is_super_user(self, user_id: Optional[str] = None) -> bool:
return user_id == self.super_user
def is_admin_user(self, user_id: str) -> bool:
diff --git a/lnbits/static/js/audit.js b/lnbits/static/js/audit.js
index 0f330f885..2541b3a3b 100644
--- a/lnbits/static/js/audit.js
+++ b/lnbits/static/js/audit.js
@@ -74,12 +74,15 @@ window.app = Vue.createApp({
search: null,
hideEmpty: true,
loading: false
+ },
+ auditDetailsDialog: {
+ data: null,
+ show: false
}
}
},
async created() {
- console.log('### audit entries')
await this.fetchAudit()
},
@@ -108,6 +111,18 @@ window.app = Vue.createApp({
await this.fetchAudit()
},
+ showDetailsDialog(entry) {
+ const details = JSON.parse(entry?.request_details || '')
+ try {
+ if (details.body) {
+ details.body = JSON.parse(details.body)
+ }
+ } catch (e) {
+ // do nothing
+ }
+ this.auditDetailsDialog.data = JSON.stringify(details, null, 4)
+ this.auditDetailsDialog.show = true
+ },
formatDate: function (value) {
return Quasar.date.formatDate(new Date(value), 'YYYY-MM-DD HH:mm')
},