From 4e9dde42c3dc23db6303471f86b54b75812f33e3 Mon Sep 17 00:00:00 2001
From: Jan Semmelink <jan@uafrica.com>
Date: Wed, 13 Oct 2021 13:43:39 +0200
Subject: [PATCH] Fix bug in service/context audit function

---
 service/context.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/service/context.go b/service/context.go
index d53caf3..79a7522 100644
--- a/service/context.go
+++ b/service/context.go
@@ -214,8 +214,9 @@ func (ctx *serviceContext) ValueOrDefault(name string, defaultValue interface{})
 }
 
 func (ctx *serviceContext) AuditChange(eventType string, orgValue, newValue interface{}) {
+	username, _ := ctx.Claim()["username"].(string)
 	event, err := audit.NewEvent(
-		ctx.Claim()["username"].(string), //use username as source (will default to "SYSTEM" if undefined)
+		username, //use username as source (will default to "SYSTEM" if undefined)
 		eventType,
 		orgValue,
 		newValue,
-- 
GitLab