Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli --must-change-password not working #19026

Closed
loynoir opened this issue Mar 8, 2022 · 8 comments
Closed

cli --must-change-password not working #19026

loynoir opened this issue Mar 8, 2022 · 8 comments
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.

Comments

@loynoir
Copy link

loynoir commented Mar 8, 2022

Gitea Version

[Docker] Gitea version 1.16.3 built with GNU Make 4.3, go1.17.6 : bindata, timetzdata, sqlite, sqlite_unlock_notif

Git Version

No response

Operating System

No response

How are you running Gitea?

cli --must-change-password not working

$ docker run -p 3000:3000 -it gitea/gitea
$ docker exec -it $(docker ps|grep gitea|awk '{print $1}') bash

Visit Initial Configuration at http://localhost:3000/

# su git
$ gitea admin user create  --username foo  --password foo  --email foo@localhost  --must-change-password false

Still need to change password when first login

But using library generated by https://github.com/OpenAPITools/openapi-generator, --must-change-password false works fine.

Database

No response

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

No response

Screenshots

No response

@zeripath
Copy link
Contributor

zeripath commented Mar 9, 2022

gitea admin user create --username foo --password foo --email foo@localhost --must-change-password=false

@zeripath
Copy link
Contributor

zeripath commented Mar 9, 2022

Note the =

@noerw
Copy link
Member

noerw commented Mar 9, 2022

Looks like only bool flags require a = separator, afaik this is fixed in urfave/cli/v2.
But that version has quite stupid issues with flag / argument order when using global flags, that might be a blocker for switching to v2.

@loynoir
Copy link
Author

loynoir commented Mar 9, 2022

gitea admin user create --username foo --password foo --email foo@localhost --must-change-password=false

Yes, confirmed working with = way

@zeripath
Copy link
Contributor

zeripath commented Mar 9, 2022

I think the BoolTFlag may have a slightly nicer behaviour.

@techknowlogick
Copy link
Member

@noerw you'll find v1 has same global ordering pattern, which we've worked around.

Gonna close this now though.

@techknowlogick techknowlogick added the type/question Issue needs no code to be fixed, only a description on how to fix it yourself. label Mar 11, 2022
@decentral1se
Copy link

@noerw you'll find v1 has same global ordering pattern, which we've worked around.

@techknowlogick oh! would you mind sharing that work-around? i'm struggling with cli ordering with urfave also...

@zeripath
Copy link
Contributor

gitea/main.go

Lines 109 to 127 in fda5b9f

// Add functions to set these paths and these flags to the commands
app.Before = establishCustomPath
for i := range app.Commands {
setFlagsAndBeforeOnSubcommands(&app.Commands[i], defaultFlags, establishCustomPath)
}
err := app.Run(os.Args)
if err != nil {
log.Fatal("Failed to run app with %s: %v", os.Args, err)
}
}
func setFlagsAndBeforeOnSubcommands(command *cli.Command, defaultFlags []cli.Flag, before cli.BeforeFunc) {
command.Flags = append(command.Flags, defaultFlags...)
command.Before = establishCustomPath
for i := range command.Subcommands {
setFlagsAndBeforeOnSubcommands(&command.Subcommands[i], defaultFlags, before)
}
}

Look at the setFlagsAndBeforeOnSubcommands

@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/question Issue needs no code to be fixed, only a description on how to fix it yourself.
Projects
None yet
Development

No branches or pull requests

5 participants