Skip to content

Commit 3a08cc3

Browse files
committed
Add must-change-password parameter.
1 parent e29e40d commit 3a08cc3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cmd/admin_user_change_password.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ var microcmdUserChangePassword = &cli.Command{
3232
Value: "",
3333
Usage: "New password to set for user",
3434
},
35+
&cli.BoolFlag{
36+
Name: "must-change-password",
37+
Usage: "User must change password",
38+
},
3539
},
3640
}
3741

@@ -69,7 +73,9 @@ func runChangePassword(c *cli.Context) error {
6973
return err
7074
}
7175

72-
if err = user_model.UpdateUserCols(ctx, user, "passwd", "passwd_hash_algo", "salt"); err != nil {
76+
user.MustChangePassword = c.Bool("must-change-password")
77+
78+
if err = user_model.UpdateUserCols(ctx, user, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil {
7379
return err
7480
}
7581

docs/content/administration/command-line.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Admin operations:
9595
- Options:
9696
- `--username value`, `-u value`: Username. Required.
9797
- `--password value`, `-p value`: New password. Required.
98+
- `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional. (default: false).
9899
- Examples:
99100
- `gitea admin user change-password --username myname --password asecurepassword`
100101
- `must-change-password`:

0 commit comments

Comments
 (0)