Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add must-change-password flag to cli for creating a user #4955

Merged
merged 9 commits into from
Oct 20, 2018
22 changes: 17 additions & 5 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}

Expand Down Expand Up @@ -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)
}
Expand Down