summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLanre Adelowo <adelowomailbox@gmail.com>2018-10-20 23:05:01 +0100
committerLauris BH <lauris@nix.lv>2018-10-21 01:05:01 +0300
commitc2748ea7fe4800331e91b9e7ff62c99181fa2ed6 (patch)
tree4b352a8187865a2e47fc9b4d46495f055374afd6 /cmd
parent5a4648cdd697be92d33be55cd85069365cce2588 (diff)
downloadgitea-c2748ea7fe4800331e91b9e7ff62c99181fa2ed6.tar.gz
gitea-c2748ea7fe4800331e91b9e7ff62c99181fa2ed6.zip
Add must-change-password flag to cli for creating a user (#4955)
* add support for an admin to force a user to change his/her password from thee cli * use BoolFlag instead * default to true * simplify by removing unnneccessary if/else
Diffstat (limited to 'cmd')
-rw-r--r--cmd/admin.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/admin.go b/cmd/admin.go
index 893b6f5be9..5ee20860ab 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -59,6 +59,10 @@ var (
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
+ cli.BoolFlag{
+ Name: "must-change-password",
+ Usage: "Force the user to change his/her password after initial login",
+ },
},
}
@@ -285,12 +289,20 @@ func runCreateUser(c *cli.Context) error {
return err
}
+ // always default to true
+ var changePassword = true
+
+ if c.IsSet("must-change-password") {
+ changePassword = c.Bool("must-change-password")
+ }
+
if err := models.CreateUser(&models.User{
- Name: c.String("name"),
- Email: c.String("email"),
- Passwd: c.String("password"),
- IsActive: true,
- IsAdmin: c.Bool("admin"),
+ Name: c.String("name"),
+ Email: c.String("email"),
+ Passwd: c.String("password"),
+ IsActive: true,
+ IsAdmin: c.Bool("admin"),
+ MustChangePassword: changePassword,
}); err != nil {
return fmt.Errorf("CreateUser: %v", err)
}