This commit is contained in:
Adrian Zürcher
2026-02-16 22:24:05 +01:00
parent 4b574d4486
commit 7d604189af
2 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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 {