admin

package
v0.0.0-...-ac44c59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:  "admin",
	Usage: "Admin commands",
	Subcommands: []*cli.Command{
		{
			Name:  "make",
			Usage: "Make user an admin",
			Action: func(ctx *cli.Context) error {
				db := ctx.Context.Value("db").(*sql.DB)
				username := ctx.Args().First()
				user, err := core.MakeAdmin(ctx.Context, db, username, true)
				if err != nil {
					return fmt.Errorf("failed to make %s an admin: %w", username, err)
				}
				log.Printf("User %s is now an admin\n", user.Username)
				return nil
			},
		},
		{
			Name:  "remove",
			Usage: "Remove user as admin",
			Action: func(ctx *cli.Context) error {
				db := ctx.Context.Value("db").(*sql.DB)
				username := ctx.Args().First()
				user, err := core.MakeAdmin(ctx.Context, db, username, false)
				if err != nil {
					return fmt.Errorf("failed to remove %s as an admin: %w", username, err)
				}
				log.Printf("User %s is no longer an admin", user.Username)
				return nil
			},
		},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL