This commit is contained in:
@@ -43,10 +43,9 @@ func SaveDB(localDBPath string, db DB) error {
|
||||
}
|
||||
|
||||
func (localdb DB) GetPool(poolname string) (common.Pool, []string, int, error) {
|
||||
pool := common.Pool{}
|
||||
pool, ok := localdb.data[poolname]
|
||||
if !ok {
|
||||
return pool, []string{}, http.StatusNotFound, fmt.Errorf("Pool %s not in localdb", poolname)
|
||||
return pool, []string{}, http.StatusNotFound, fmt.Errorf("pool %s not in localdb", poolname)
|
||||
}
|
||||
return pool, []string{}, http.StatusOK, nil
|
||||
}
|
||||
|
||||
+17
-17
@@ -149,7 +149,7 @@ func Run() {
|
||||
router.GET("/pools/:poolid", func(c *gin.Context) {
|
||||
poolid, ok := c.Params.Get("poolid")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func Run() {
|
||||
router.POST("/pools/:poolid", func(c *gin.Context) {
|
||||
poolid, ok := c.Params.Get("poolid")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ func Run() {
|
||||
router.DELETE("/pools/:poolid", func(c *gin.Context) {
|
||||
poolid, ok := c.Params.Get("poolid")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ func Run() {
|
||||
router.GET("/groups/:groupname", func(c *gin.Context) {
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func Run() {
|
||||
router.POST("/groups/:groupname", func(c *gin.Context) {
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ func Run() {
|
||||
router.DELETE("/groups/:groupname", func(c *gin.Context) {
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -292,13 +292,13 @@ func Run() {
|
||||
router.POST("/pools/:poolid/groups/:groupname", func(c *gin.Context) {
|
||||
poolid, ok := c.Params.Get("poolid")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -325,13 +325,13 @@ func Run() {
|
||||
router.DELETE("/pools/:poolid/groups/:groupname", func(c *gin.Context) {
|
||||
poolid, ok := c.Params.Get("poolid")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ func Run() {
|
||||
router.GET("/users/:username", func(c *gin.Context) {
|
||||
username_str, ok := c.Params.Get("username")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter poolid")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter poolid")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ func Run() {
|
||||
router.POST("/users/:username", func(c *gin.Context) {
|
||||
username_str, ok := c.Params.Get("username")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ func Run() {
|
||||
router.DELETE("/users/:username", func(c *gin.Context) {
|
||||
username_str, ok := c.Params.Get("username")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -451,13 +451,13 @@ func Run() {
|
||||
router.POST("/groups/:groupname/users/:username", func(c *gin.Context) {
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
username_str, ok := c.Params.Get("username")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter username")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter username")})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -490,13 +490,13 @@ func Run() {
|
||||
router.DELETE("/groups/:groupname/users/:username", func(c *gin.Context) {
|
||||
groupname_str, ok := c.Params.Get("groupname")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter groupname")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter groupname")})
|
||||
return
|
||||
}
|
||||
|
||||
username_str, ok := c.Params.Get("username")
|
||||
if !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("Missing required path parameter username")})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Errorf("missing required path parameter username")})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -153,9 +153,7 @@ func (pve ProxmoxClient) GetGroup(groupname common.Groupname) (common.Group, []s
|
||||
|
||||
group.Groupname, _ = common.ParseGroupname(pvegroup.GroupID)
|
||||
|
||||
for _, userid := range pvegroup.Members {
|
||||
members = append(members, userid)
|
||||
}
|
||||
members = append(members, pvegroup.Members...)
|
||||
|
||||
return group, members, http.StatusOK, nil
|
||||
}
|
||||
@@ -306,7 +304,7 @@ func (pve ProxmoxClient) DelUserFromGroup(username common.Username, groupname co
|
||||
|
||||
idx := slices.Index(user.Groups, groupname.ToString())
|
||||
if idx < 0 {
|
||||
return http.StatusBadRequest, fmt.Errorf("Did not find group %s in user groups {%+v}.", groupname.ToString(), user.Groups)
|
||||
return http.StatusBadRequest, fmt.Errorf("did not find group %s in user groups {%+v}", groupname.ToString(), user.Groups)
|
||||
}
|
||||
newGroups := slices.Delete(user.Groups, idx, idx)
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ func GetUserSessionFromContext(c *gin.Context) (*UserSession, int, error) {
|
||||
session := sessions.Default(c)
|
||||
SessionUUID := session.Get("SessionUUID")
|
||||
if SessionUUID == nil {
|
||||
return nil, http.StatusUnauthorized, fmt.Errorf("No auth session found")
|
||||
return nil, http.StatusUnauthorized, fmt.Errorf("no auth session found")
|
||||
}
|
||||
uuid := SessionUUID.(string)
|
||||
usersession := UserSessions[uuid]
|
||||
|
||||
Reference in New Issue
Block a user