From 3a08cc33f36907f5926925a336e30a004426719b Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 14 Oct 2023 15:39:47 +0000 Subject: [PATCH 1/6] Add must-change-password parameter. --- cmd/admin_user_change_password.go | 8 +++++++- docs/content/administration/command-line.en-us.md | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index eebbfb3b6710d..a94836740bdfe 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -32,6 +32,10 @@ var microcmdUserChangePassword = &cli.Command{ Value: "", Usage: "New password to set for user", }, + &cli.BoolFlag{ + Name: "must-change-password", + Usage: "User must change password", + }, }, } @@ -69,7 +73,9 @@ func runChangePassword(c *cli.Context) error { return err } - if err = user_model.UpdateUserCols(ctx, user, "passwd", "passwd_hash_algo", "salt"); err != nil { + 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 } diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md index a52b93d344cd0..ffb1dc8eecb9b 100644 --- a/docs/content/administration/command-line.en-us.md +++ b/docs/content/administration/command-line.en-us.md @@ -95,6 +95,7 @@ Admin operations: - Options: - `--username value`, `-u value`: Username. 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. (default: false). - Examples: - `gitea admin user change-password --username myname --password asecurepassword` - `must-change-password`: From 77e2e234f1bd8f9d920df50d0d0d75a0d44a7447 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Tue, 17 Oct 2023 14:15:37 +0000 Subject: [PATCH 2/6] Use `must-not-change-password`. --- cmd/admin_user_change_password.go | 6 +++--- docs/content/administration/command-line.en-us.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index a94836740bdfe..733ae7c63966d 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -33,8 +33,8 @@ var microcmdUserChangePassword = &cli.Command{ Usage: "New password to set for user", }, &cli.BoolFlag{ - Name: "must-change-password", - Usage: "User must change password", + Name: "must-not-change-password", + Usage: "The user is not required to choose a new password after the login", }, }, } @@ -73,7 +73,7 @@ func runChangePassword(c *cli.Context) error { return err } - user.MustChangePassword = c.Bool("must-change-password") + user.MustChangePassword = !c.Bool("must-not-change-password") if err = user_model.UpdateUserCols(ctx, user, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil { return err diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md index ffb1dc8eecb9b..bc836678c6f10 100644 --- a/docs/content/administration/command-line.en-us.md +++ b/docs/content/administration/command-line.en-us.md @@ -95,7 +95,7 @@ Admin operations: - Options: - `--username value`, `-u value`: Username. 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. (default: false). + - `--must-not-change-password`: If provided, the user is not required to choose a new password after the login. Optional. - Examples: - `gitea admin user change-password --username myname --password asecurepassword` - `must-change-password`: From dab43ff00668053374c3371e7e330a680d9ff398 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 20 Oct 2023 14:04:22 +0200 Subject: [PATCH 3/6] Revert "Use `must-not-change-password`." This reverts commit 77e2e234f1bd8f9d920df50d0d0d75a0d44a7447. --- cmd/admin_user_change_password.go | 6 +++--- docs/content/administration/command-line.en-us.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index 733ae7c63966d..a94836740bdfe 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -33,8 +33,8 @@ var microcmdUserChangePassword = &cli.Command{ Usage: "New password to set for user", }, &cli.BoolFlag{ - Name: "must-not-change-password", - Usage: "The user is not required to choose a new password after the login", + Name: "must-change-password", + Usage: "User must change password", }, }, } @@ -73,7 +73,7 @@ func runChangePassword(c *cli.Context) error { return err } - user.MustChangePassword = !c.Bool("must-not-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 diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md index bc836678c6f10..ffb1dc8eecb9b 100644 --- a/docs/content/administration/command-line.en-us.md +++ b/docs/content/administration/command-line.en-us.md @@ -95,7 +95,7 @@ Admin operations: - Options: - `--username value`, `-u value`: Username. Required. - `--password value`, `-p value`: New password. Required. - - `--must-not-change-password`: If provided, the user is not required to choose a new password after the login. Optional. + - `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional. (default: false). - Examples: - `gitea admin user change-password --username myname --password asecurepassword` - `must-change-password`: From 2b0145d12f87fade02efa4f4dddb623ed9c97e90 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 20 Oct 2023 14:06:19 +0200 Subject: [PATCH 4/6] true by default --- cmd/admin_user_change_password.go | 1 + docs/content/administration/command-line.en-us.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index a94836740bdfe..f1b08c197e64f 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -34,6 +34,7 @@ var microcmdUserChangePassword = &cli.Command{ }, &cli.BoolFlag{ Name: "must-change-password", + Value: true, Usage: "User must change password", }, }, diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md index ffb1dc8eecb9b..e3d7fe5a79d72 100644 --- a/docs/content/administration/command-line.en-us.md +++ b/docs/content/administration/command-line.en-us.md @@ -95,7 +95,7 @@ Admin operations: - Options: - `--username value`, `-u value`: Username. 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. (default: false). + - `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional. (default: true). - Examples: - `gitea admin user change-password --username myname --password asecurepassword` - `must-change-password`: From 6b75f9769f52838df8d86ab490d9ad36ee60c7cb Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 3 Feb 2024 15:27:22 +0000 Subject: [PATCH 5/6] Add suggestion. --- cmd/admin_user_change_password.go | 3 +-- docs/content/administration/command-line.en-us.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index f1b08c197e64f..a441777085d09 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -34,7 +34,6 @@ var microcmdUserChangePassword = &cli.Command{ }, &cli.BoolFlag{ Name: "must-change-password", - Value: true, Usage: "User must change password", }, }, @@ -74,7 +73,7 @@ func runChangePassword(c *cli.Context) error { return err } - user.MustChangePassword = c.Bool("must-change-password") + user.MustChangePassword = c.IsSet("must-change-password") if err = user_model.UpdateUserCols(ctx, user, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil { return err diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md index e3d7fe5a79d72..5049df35e0504 100644 --- a/docs/content/administration/command-line.en-us.md +++ b/docs/content/administration/command-line.en-us.md @@ -95,7 +95,7 @@ Admin operations: - Options: - `--username value`, `-u value`: Username. 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. (default: true). + - `--must-change-password`: If provided, the user is required to choose a new password after the login. Optional. - Examples: - `gitea admin user change-password --username myname --password asecurepassword` - `must-change-password`: From 908e69e6de0ab50dac6c0b5397b2e7c50d78f8c1 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 3 Feb 2024 15:37:52 +0000 Subject: [PATCH 6/6] Use real value. --- cmd/admin_user_change_password.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index a441777085d09..22764318fdbb3 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -73,7 +73,9 @@ func runChangePassword(c *cli.Context) error { return err } - user.MustChangePassword = c.IsSet("must-change-password") + 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