From 2989a1e74908a70801c3e7413ea8670d18f962c0 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Mon, 10 Jul 2023 18:53:21 +0100 Subject: [PATCH] Improve error message output for checkAuthForCertificate --- servers/auth.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/servers/auth.go b/servers/auth.go index 0a34aab..cb0f00f 100644 --- a/servers/auth.go +++ b/servers/auth.go @@ -6,6 +6,7 @@ import ( "github.com/MrMelon54/mjwt/auth" vUtils "github.com/MrMelon54/violet/utils" "github.com/julienschmidt/httprouter" + "log" "net/http" ) @@ -57,7 +58,12 @@ func checkAuthForCertificate(verify mjwt.Verifier, perm string, db *sql.DB, cb C // lookup certificate owner id, err := checkCertOwner(db, params.ByName("id"), b) if err != nil { + if err.Error() == "not the certificate owner" { + apiError(rw, http.StatusBadRequest, "Not the certificate owner") + return + } apiError(rw, http.StatusInsufficientStorage, "Database error") + log.Println("[API] Failed to find certificate owner: ", err) return }