mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix(admin): keep must_change_password unless it is passed to user edit
--must-change-password defaulted to true on admin user edit as well, so changing a password with --password silently forced the user to change it again at the next sign-in. On edit the flag now defaults to unset and is sent only when passed; create keeps requiring a change by default. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
2 files changed
+25
-3
No files matched your search
@@ -73,7 +73,7 @@ func (a *application) adminCommand() *cobra.Command {
|
||||
}
|
||||
command.Flags().StringVar(&password, "password", "", "Password (prefer --password-file)")
|
||||
command.Flags().StringVar(&passwordFile, "password-file", "", "Read password from file or - for stdin; remove one trailing line ending")
|
||||
command.Flags().BoolVar(&mustChangePassword, "must-change-password", true, "Require password change on next sign-in (use =false to disable)")
|
||||
command.Flags().BoolVar(&mustChangePassword, "must-change-password", verb == "create", "Require password change on next sign-in (use =false to disable)")
|
||||
}
|
||||
command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||
if verb == "create" {
|
||||
@@ -161,8 +161,8 @@ func (a *application) adminCommand() *cobra.Command {
|
||||
return clierr.Wrap(clierr.Usage, errors.New("password cannot be empty"))
|
||||
}
|
||||
opts.Password = password
|
||||
opts.MustChangePassword = &mustChangePassword
|
||||
} else if cmd.Flags().Changed("must-change-password") {
|
||||
}
|
||||
if verb == "create" || cmd.Flags().Changed("must-change-password") {
|
||||
opts.MustChangePassword = &mustChangePassword
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user