|
59 | 59 | Value: "custom/conf/app.ini",
|
60 | 60 | Usage: "Custom configuration file path",
|
61 | 61 | },
|
| 62 | + cli.BoolFlag{ |
| 63 | + Name: "must-change-password", |
| 64 | + Usage: "Force the user to change his/her password after initial login", |
| 65 | + }, |
62 | 66 | },
|
63 | 67 | }
|
64 | 68 |
|
@@ -285,12 +289,20 @@ func runCreateUser(c *cli.Context) error {
|
285 | 289 | return err
|
286 | 290 | }
|
287 | 291 |
|
| 292 | + // always default to true |
| 293 | + var changePassword = true |
| 294 | + |
| 295 | + if c.IsSet("must-change-password") { |
| 296 | + changePassword = c.Bool("must-change-password") |
| 297 | + } |
| 298 | + |
288 | 299 | if err := models.CreateUser(&models.User{
|
289 |
| - Name: c.String("name"), |
290 |
| - Email: c.String("email"), |
291 |
| - Passwd: c.String("password"), |
292 |
| - IsActive: true, |
293 |
| - IsAdmin: c.Bool("admin"), |
| 300 | + Name: c.String("name"), |
| 301 | + Email: c.String("email"), |
| 302 | + Passwd: c.String("password"), |
| 303 | + IsActive: true, |
| 304 | + IsAdmin: c.Bool("admin"), |
| 305 | + MustChangePassword: changePassword, |
294 | 306 | }); err != nil {
|
295 | 307 | return fmt.Errorf("CreateUser: %v", err)
|
296 | 308 | }
|
|
0 commit comments