Skip to content

Commit

Permalink
Merge pull request #251 from jwessel/feat_user_udpate
Browse files Browse the repository at this point in the history
feat: Allow for update or removal of the invite token
  • Loading branch information
moul authored Mar 26, 2021
2 parents be3f215 + 5b43320 commit e455d50
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/bastion/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -1736,6 +1736,8 @@ GLOBAL OPTIONS:
Flags: []cli.Flag{
cli.StringFlag{Name: "name, n", Usage: "Renames the user"},
cli.StringFlag{Name: "email, e", Usage: "Updates the email"},
cli.StringFlag{Name: "invite_token, i", Usage: "Updates the invite token"},
cli.BoolFlag{Name: "remove_invite, R", Usage: "Remove invite token"},
cli.StringSliceFlag{Name: "assign-role, r", Usage: "Assign the user to new `USERROLES`"},
cli.StringSliceFlag{Name: "unassign-role", Usage: "Unassign the user from `USERROLES`"},
cli.StringSliceFlag{Name: "assign-group, g", Usage: "Assign the user to new `USERGROUPS`"},
Expand Down Expand Up @@ -1768,14 +1770,21 @@ GLOBAL OPTIONS:
for _, user := range users {
model := tx.Model(user)
// simple fields
for _, fieldname := range []string{"name", "email", "comment"} {
for _, fieldname := range []string{"name", "email", "comment", "invite_token"} {
if c.String(fieldname) != "" {
if err := model.Update(fieldname, c.String(fieldname)).Error; err != nil {
tx.Rollback()
return err
}
}
}
// invite remove
if c.Bool("remove_invite") {
if err := model.Update("invite_token", "").Error; err != nil {
tx.Rollback()
return err
}
}

// associations
var appendGroups []dbmodels.UserGroup
Expand Down

0 comments on commit e455d50

Please sign in to comment.