0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-11 20:41:34 +01:00

Add "restricted" option to create user command

This commit is contained in:
Jimmy Praet 2022-04-02 18:34:47 +02:00
parent 4172f3f74b
commit f747cdd36f

View file

@ -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",
},
},
}
@ -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"),
@ -570,6 +580,7 @@ func runCreateUser(c *cli.Context) error {
overwriteDefault := &user_model.CreateUserOverwriteOptions{
IsActive: util.OptionalBoolTrue,
IsRestricted: restricted,
}
if err := user_model.CreateUser(u, overwriteDefault); err != nil {