Skip to content

Admin CLI create-user not honoring lack of must-change-password flag #6005

Closed
@jolheiser

Description

@jolheiser
  • Gitea version (or commit ref): master
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

If the CLI is used to create a user, lack of the must-change-password flag would imply that the new user doesn't need to change their password, however that is not what happens.

When creating a user via the CLI, the must-change-password flag loses meaning after the first user is created (presumably the admin)

// always default to true
var changePassword = true

// If this is the first user being created.
// Take it as the admin and don't force a password update.
if n := models.CountUsers(); n == 0 {
    changePassword = false
}

if c.IsSet("must-change-password") {
    changePassword = c.Bool("must-change-password")
}

I think there are probably two options based on the "wanted" default behavior.

  1. Set changePassword to false by default, as that will line up with the intended use of the flag.
  2. Remove the must-change-password flag and optionally add a different flag with the opposite meaning. This would mean that users created via CLI would, by default, need to change their password, unless the new flag is applied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions