Skip to content

Commit

Permalink
fix: "unsupported relations: Roles" when using unassign-group on a …
Browse files Browse the repository at this point in the history
…user

moul#329
  • Loading branch information
korween authored and libvoid committed Jun 5, 2023
1 parent 103e8d8 commit 49a52c4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/bastion/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -1955,12 +1955,15 @@ GLOBAL OPTIONS:
tx.Rollback()
return err
}
if err := model.Association("Groups").Append(&appendGroups); err != nil {

groups := tx.Model(user).Association("Groups")

if err := groups.Append(&appendGroups); err != nil {
tx.Rollback()
return err
}
if len(deleteGroups) > 0 {
if err := model.Association("Groups").Delete(deleteGroups); err != nil {
if err := groups.Delete(deleteGroups); err != nil {
tx.Rollback()
return err
}
Expand All @@ -1975,12 +1978,15 @@ GLOBAL OPTIONS:
tx.Rollback()
return err
}
if err := model.Association("Roles").Append(&appendRoles); err != nil {

roles := tx.Model(user).Association("Groups")

if err := roles.Append(&appendRoles); err != nil {
tx.Rollback()
return err
}
if len(deleteRoles) > 0 {
if err := model.Association("Roles").Delete(deleteRoles); err != nil {
if err := roles.Delete(deleteRoles); err != nil {
tx.Rollback()
return err
}
Expand Down

0 comments on commit 49a52c4

Please sign in to comment.