Improve error message output for checkAuthForCertificate

This commit is contained in:
Melon 2023-07-10 18:53:21 +01:00
parent 04551ec3bb
commit 2989a1e749
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -6,6 +6,7 @@ import (
"github.com/MrMelon54/mjwt/auth" "github.com/MrMelon54/mjwt/auth"
vUtils "github.com/MrMelon54/violet/utils" vUtils "github.com/MrMelon54/violet/utils"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
"log"
"net/http" "net/http"
) )
@ -57,7 +58,12 @@ func checkAuthForCertificate(verify mjwt.Verifier, perm string, db *sql.DB, cb C
// lookup certificate owner // lookup certificate owner
id, err := checkCertOwner(db, params.ByName("id"), b) id, err := checkCertOwner(db, params.ByName("id"), b)
if err != nil { 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") apiError(rw, http.StatusInsufficientStorage, "Database error")
log.Println("[API] Failed to find certificate owner: ", err)
return return
} }