diff --git a/handlers/workspace.go b/handlers/workspace.go index f3fbe71..8ad74e5 100644 --- a/handlers/workspace.go +++ b/handlers/workspace.go @@ -24,7 +24,7 @@ func (aH *AccessHandler) AddWorkspace(c *gin.Context) { } // Check if a workspace with this name already exists - if aH.dbHandler.Exists(&models.Workspace{}, "workspace", workspace.Name, false) { + if aH.dbHandler.Exists(&models.Workspace{}, "name", workspace.Name, false) { aH.logger.Error("AddWorkspace", fmt.Sprintf("workspace with name %s already exists", workspace.Name)) c.JSON(http.StatusBadRequest, models.NewJsonMessageResponse(fmt.Sprintf("workspace with name %s already exists", workspace.Name))) return @@ -120,7 +120,7 @@ func (aH *AccessHandler) DeleteWorkspace(c *gin.Context) { } for _, workspace := range request.Workspaces { - err = aH.dbHandler.DeleteByKey(&models.Workspace{}, "id", workspace, false) + err = aH.dbHandler.DeleteByKey(&models.Workspace{}, "id", workspace.Id, false) if err != nil { aH.logger.Error("DeleteWorkspace", err) c.JSON(http.StatusInternalServerError, nil) diff --git a/models/user.go b/models/user.go index 7fdf3bb..6e79aa9 100644 --- a/models/user.go +++ b/models/user.go @@ -14,7 +14,7 @@ type User struct { NewPassword string `gorm:"-" json:"newPassword,omitempty"` Expiration string `gorm:"column:expiration" json:"expiration,omitempty"` Settings Settings `gorm:"type:json" json:"settings"` - Workspaces []*Workspace `gorm:"many2many:users_workspaces;" ` + Workspaces []*Workspace `gorm:"many2many:users_workspaces;" json:"workspaces"` } func (u *User) IsValid() bool {