Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add "restricted" option to create user command
  • Loading branch information
jpraet committed Apr 2, 2022
commit f747cdd36f8d2e0c273cd37e81ca4b09114563a3
13 changes: 12 additions & 1 deletion cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ var (
Name: "access-token",
Usage: "Generate access token for the user",
},
cli.BoolFlag{
Name: "restricted",
Usage: "Make a restricted user account",
},
},
}

Expand Down Expand Up @@ -560,6 +564,12 @@ func runCreateUser(c *cli.Context) error {
changePassword = c.Bool("must-change-password")
}

restricted := util.OptionalBoolNone

if c.IsSet("restricted") {
restricted = util.OptionalBoolOf(c.Bool("restricted"))
}

u := &user_model.User{
Name: username,
Email: c.String("email"),
Expand All @@ -569,7 +579,8 @@ func runCreateUser(c *cli.Context) error {
}

overwriteDefault := &user_model.CreateUserOverwriteOptions{
IsActive: util.OptionalBoolTrue,
IsActive: util.OptionalBoolTrue,
IsRestricted: restricted,
}

if err := user_model.CreateUser(u, overwriteDefault); err != nil {
Expand Down