This commit is contained in:
2023-04-03 11:04:52 +10:00
parent 8432286101
commit c229e93103
6 changed files with 86 additions and 2 deletions

View File

@@ -123,3 +123,15 @@ func CurrentUser(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "success", "data": u})
}
func GetRoles(c *gin.Context) {
roles, err := models.QueryRoles()
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"message": "success", "data": roles})
}

View File

@@ -42,6 +42,11 @@ func StoreSecret(c *gin.Context) {
s.RoleId = 1
}
if input.DeviceCategory == "" && input.DeviceName == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "cannot store secret with empty deviceName and empty deviceCategory"})
return
}
// If this secret already exists in the database then generate an error
checkExists, err := models.GetSecrets(&s)
if err != nil {