From ace0a9052c80bb964d1d545e122ad9a456ee8c24 Mon Sep 17 00:00:00 2001 From: franzmueller Date: Tue, 30 Jan 2024 09:02:24 +0100 Subject: [PATCH] add check for missing X-UserId header --- lib/api/api.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/api/api.go b/lib/api/api.go index 750d6dd..cba75c3 100644 --- a/lib/api/api.go +++ b/lib/api/api.go @@ -60,5 +60,9 @@ func getUserId(request *http.Request) (string, error) { } return forUser, nil } - return request.Header.Get("X-UserId"), nil + userid := request.Header.Get("X-UserId") + if userid == "" { + return "", errors.New("X-UserId not set") + } + return userid, nil }