mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-02 03:20:34 +02:00
allow default-token and per-subscription tokens in client.yml
This commit is contained in:
parent
477c9d3ed5
commit
25be5b47e4
11 changed files with 572 additions and 65 deletions
cmd
|
@ -154,25 +154,28 @@ func execPublish(c *cli.Context) error {
|
|||
}
|
||||
if token != "" {
|
||||
options = append(options, client.WithBearerAuth(token))
|
||||
}
|
||||
if user != "" {
|
||||
var pass string
|
||||
parts := strings.SplitN(user, ":", 2)
|
||||
if len(parts) == 2 {
|
||||
user = parts[0]
|
||||
pass = parts[1]
|
||||
} else {
|
||||
fmt.Fprint(c.App.ErrWriter, "Enter Password: ")
|
||||
p, err := util.ReadPassword(c.App.Reader)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
if user != "" {
|
||||
var pass string
|
||||
parts := strings.SplitN(user, ":", 2)
|
||||
if len(parts) == 2 {
|
||||
user = parts[0]
|
||||
pass = parts[1]
|
||||
} else {
|
||||
fmt.Fprint(c.App.ErrWriter, "Enter Password: ")
|
||||
p, err := util.ReadPassword(c.App.Reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pass = string(p)
|
||||
fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20))
|
||||
}
|
||||
pass = string(p)
|
||||
fmt.Fprintf(c.App.ErrWriter, "\r%s\r", strings.Repeat(" ", 20))
|
||||
options = append(options, client.WithBasicAuth(user, pass))
|
||||
} else if conf.DefaultToken != "" {
|
||||
options = append(options, client.WithBearerAuth(conf.DefaultToken))
|
||||
} else if conf.DefaultUser != "" && conf.DefaultPassword != nil {
|
||||
options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword))
|
||||
}
|
||||
options = append(options, client.WithBasicAuth(user, pass))
|
||||
} else if token == "" && conf.DefaultUser != "" && conf.DefaultPassword != nil {
|
||||
options = append(options, client.WithBasicAuth(conf.DefaultUser, *conf.DefaultPassword))
|
||||
}
|
||||
if pid > 0 {
|
||||
newMessage, err := waitForProcess(pid)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue