2022-01-23 21:30:30 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
var flagsDeny = userCommandFlags()
|
|
|
|
var cmdDeny = &cli.Command{
|
|
|
|
Name: "deny",
|
|
|
|
Usage: "Revoke user access from a topic",
|
|
|
|
UsageText: "ntfy deny USERNAME TOPIC",
|
|
|
|
Flags: flagsDeny,
|
|
|
|
Before: initConfigFileInputSource("config", flagsDeny),
|
|
|
|
Action: execUserDeny,
|
|
|
|
Category: categoryServer,
|
|
|
|
}
|
|
|
|
|
|
|
|
func execUserDeny(c *cli.Context) error {
|
|
|
|
username := c.Args().Get(0)
|
|
|
|
topic := c.Args().Get(1)
|
|
|
|
if username == "" {
|
2022-01-24 05:02:39 +01:00
|
|
|
return errors.New("username expected, type 'ntfy deny --help' for help")
|
2022-01-23 21:30:30 +01:00
|
|
|
} else if topic == "" {
|
2022-01-24 05:02:39 +01:00
|
|
|
return errors.New("topic expected, type 'ntfy deny --help' for help")
|
2022-01-23 21:30:30 +01:00
|
|
|
}
|
2022-01-24 05:02:39 +01:00
|
|
|
if username == userEveryone {
|
2022-01-23 21:30:30 +01:00
|
|
|
username = ""
|
|
|
|
}
|
|
|
|
manager, err := createAuthManager(c)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return doAccessAllow(c, manager, username, topic, false, false)
|
|
|
|
}
|