mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 08:23:56 +01:00
Add must-change-password
cli parameter (#27626)
This PR adds a new `must-change-password` parameter to the `change-password` cli command. We already have the `must-change-password` command but it feels natural to have this integrated into the `change-password` cli command. --------- Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
360b3fd17c
commit
9bea276055
2 changed files with 10 additions and 1 deletions
|
@ -32,6 +32,10 @@ var microcmdUserChangePassword = &cli.Command{
|
||||||
Value: "",
|
Value: "",
|
||||||
Usage: "New password to set for user",
|
Usage: "New password to set for user",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "must-change-password",
|
||||||
|
Usage: "User must change password",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +73,11 @@ func runChangePassword(c *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = user_model.UpdateUserCols(ctx, user, "passwd", "passwd_hash_algo", "salt"); err != nil {
|
if c.IsSet("must-change-password") {
|
||||||
|
user.MustChangePassword = c.Bool("must-change-password")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = user_model.UpdateUserCols(ctx, user, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ Admin operations:
|
||||||
- Options:
|
- Options:
|
||||||
- `--username value`, `-u value`: Username. Required.
|
- `--username value`, `-u value`: Username. Required.
|
||||||
- `--password value`, `-p value`: New password. Required.
|
- `--password value`, `-p value`: New password. Required.
|
||||||
|
- `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional.
|
||||||
- Examples:
|
- Examples:
|
||||||
- `gitea admin user change-password --username myname --password asecurepassword`
|
- `gitea admin user change-password --username myname --password asecurepassword`
|
||||||
- `must-change-password`:
|
- `must-change-password`:
|
||||||
|
|
Loading…
Reference in a new issue