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:
parent
4172f3f74b
commit
f747cdd36f
1 changed files with 12 additions and 1 deletions
11
cmd/admin.go
11
cmd/admin.go
|
@ -115,6 +115,10 @@ var (
|
||||||
Name: "access-token",
|
Name: "access-token",
|
||||||
Usage: "Generate access token for the user",
|
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")
|
changePassword = c.Bool("must-change-password")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restricted := util.OptionalBoolNone
|
||||||
|
|
||||||
|
if c.IsSet("restricted") {
|
||||||
|
restricted = util.OptionalBoolOf(c.Bool("restricted"))
|
||||||
|
}
|
||||||
|
|
||||||
u := &user_model.User{
|
u := &user_model.User{
|
||||||
Name: username,
|
Name: username,
|
||||||
Email: c.String("email"),
|
Email: c.String("email"),
|
||||||
|
@ -570,6 +580,7 @@ func runCreateUser(c *cli.Context) error {
|
||||||
|
|
||||||
overwriteDefault := &user_model.CreateUserOverwriteOptions{
|
overwriteDefault := &user_model.CreateUserOverwriteOptions{
|
||||||
IsActive: util.OptionalBoolTrue,
|
IsActive: util.OptionalBoolTrue,
|
||||||
|
IsRestricted: restricted,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user_model.CreateUser(u, overwriteDefault); err != nil {
|
if err := user_model.CreateUser(u, overwriteDefault); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue