keys: Add checks

This commit is contained in:
nemunaire 2022-09-04 17:59:51 +02:00
commit ba98b9ed69
2 changed files with 9 additions and 3 deletions

View file

@ -51,6 +51,11 @@ func declareAPIAuthKeysRoutes(router *gin.RouterGroup) {
return
}
if err := key.CheckKey(); err != nil {
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
return
}
k, err := u.NewKey(key.Type, key.Content)
if err != nil {
log.Println("Unable to NewKey:", err)