change user db structure for workspaces
This commit is contained in:
@@ -127,6 +127,7 @@ func (aH *AccessHandler) Login(c *gin.Context) {
|
|||||||
"user": user.Name,
|
"user": user.Name,
|
||||||
"role": user.Role.Role,
|
"role": user.Role.Role,
|
||||||
"settings": user.Settings,
|
"settings": user.Settings,
|
||||||
|
"workspace": user.WorkspaceID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +227,7 @@ func (aH *AccessHandler) Me(c *gin.Context) {
|
|||||||
"id": claims["id"],
|
"id": claims["id"],
|
||||||
"user": claims["username"],
|
"user": claims["username"],
|
||||||
"role": claims["role"],
|
"role": claims["role"],
|
||||||
|
"workspace": claims["workspace"],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,10 +156,10 @@ func (aH *AccessHandler) DeleteWorkspace(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
if u.Settings.Workspace == nil {
|
if u.WorkspaceID == nil {
|
||||||
continue
|
continue
|
||||||
} else if u.Settings.Workspace.Uuid.String() == workspace.Uuid.String() {
|
} else if *u.WorkspaceID == workspace.Id {
|
||||||
u.Settings.Workspace = nil
|
u.WorkspaceID = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
u.Workspaces = slices.DeleteFunc(u.Workspaces, func(w *models.Workspace) bool {
|
u.Workspaces = slices.DeleteFunc(u.Workspaces, func(w *models.Workspace) bool {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ type Settings struct {
|
|||||||
AppName string `json:"appName,omitempty"`
|
AppName string `json:"appName,omitempty"`
|
||||||
DatabaseName string `json:"databaseName,omitempty"`
|
DatabaseName string `json:"databaseName,omitempty"`
|
||||||
DatabaseToken string `json:"databaseToken,omitempty"`
|
DatabaseToken string `json:"databaseToken,omitempty"`
|
||||||
Workspace *Workspace `json:"workspace,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Settings) DefaultQuasarSettings() {
|
func (s *Settings) DefaultQuasarSettings() {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type User struct {
|
|||||||
Expiration string `gorm:"column:expiration" json:"expiration,omitempty"`
|
Expiration string `gorm:"column:expiration" json:"expiration,omitempty"`
|
||||||
Settings Settings `gorm:"type:json" json:"settings"`
|
Settings Settings `gorm:"type:json" json:"settings"`
|
||||||
Workspaces []*Workspace `gorm:"many2many:users_workspaces;" json:"workspaces"`
|
Workspaces []*Workspace `gorm:"many2many:users_workspaces;" json:"workspaces"`
|
||||||
|
WorkspaceID *uint `gorm:"column:workspaceId" json:"workspaceId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) IsValid() bool {
|
func (u *User) IsValid() bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user