Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
d89d3eaebf
commit
d7710adce0
|
@ -19,10 +19,6 @@ var AuthAddFlags = []cli.Flag{
|
|||
Name: "name, n",
|
||||
Usage: "arbitrary name to help identify the access `TOKEN`",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "user, u",
|
||||
Usage: "`USERNAME` of the account the access token belongs to (leave empty for none)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "scope, s",
|
||||
Usage: "authorization `SCOPE` for the access token e.g. \"metrics\" or \"photos albums\" (\"*\" to allow all scopes)",
|
||||
|
@ -38,6 +34,8 @@ var AuthAddFlags = []cli.Flag{
|
|||
var AuthAddCommand = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "Creates a new client access token",
|
||||
Description: "Specifying a username as argument creates a personal access token for a registered user account.",
|
||||
ArgsUsage: "[username]",
|
||||
Flags: AuthAddFlags,
|
||||
Action: authAddAction,
|
||||
}
|
||||
|
@ -46,7 +44,7 @@ var AuthAddCommand = cli.Command{
|
|||
func authAddAction(ctx *cli.Context) error {
|
||||
return CallWithDependencies(ctx, func(conf *config.Config) error {
|
||||
// Get username from command flag.
|
||||
userName := ctx.String("user")
|
||||
userName := clean.Username(ctx.Args().First())
|
||||
|
||||
// Find user account.
|
||||
user := entity.FindUserByName(userName)
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
// Usage hints for the client management subcommands.
|
||||
const (
|
||||
ClientNameUsage = "arbitrary name to help identify the `CLIENT` application"
|
||||
ClientUserName = "`USERNAME` of the account the client application belongs to (leave empty for none)"
|
||||
ClientAuthScope = "authorization `SCOPE` of the client e.g. \"metrics\" or \"photos albums\" (\"*\" to allow all scopes)"
|
||||
ClientAuthMethod = "supported authentication `METHOD` for the client application"
|
||||
ClientAuthExpires = "access token lifetime in `SECONDS`, after which a new token must be created by the client (-1 to disable)"
|
||||
|
@ -40,10 +39,6 @@ var ClientAddFlags = []cli.Flag{
|
|||
Name: "name, n",
|
||||
Usage: ClientNameUsage,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "user, u",
|
||||
Usage: ClientUserName,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "scope, s",
|
||||
Usage: ClientAuthScope,
|
||||
|
|
|
@ -20,6 +20,8 @@ import (
|
|||
var ClientsAddCommand = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "Registers a new client application",
|
||||
Description: "Specifying a username as argument will assign the client application to a registered user account.",
|
||||
ArgsUsage: "[username]",
|
||||
Flags: ClientAddFlags,
|
||||
Action: clientsAddAction,
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func NewClientFromCli(ctx *cli.Context) Client {
|
|||
f.AuthScope = "webdav"
|
||||
}
|
||||
|
||||
if user := ctx.String("user"); rnd.IsUID(user, 'u') {
|
||||
if user := clean.Username(ctx.Args().First()); rnd.IsUID(user, 'u') {
|
||||
f.UserUID = user
|
||||
} else if user != "" {
|
||||
f.UserName = user
|
||||
|
|
Loading…
Reference in New Issue
Block a user