From f747cdd36f8d2e0c273cd37e81ca4b09114563a3 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Sat, 2 Apr 2022 18:34:47 +0200 Subject: [PATCH] Add "restricted" option to create user command --- cmd/admin.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/admin.go b/cmd/admin.go index 722ecdd8a9..36cac50a47 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -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"), @@ -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 {