Add commands to remove logins and users

This commit is contained in:
Andreas Schneider 2020-10-18 15:19:16 +02:00
parent 0ea1de332b
commit 5a8750e637
1 changed files with 29 additions and 6 deletions

View File

@ -34,11 +34,13 @@ import (
) )
type CmdShare struct { type CmdShare struct {
CmdList CmdShareList `cmd:"" name:"list" help:"List all shares."` CmdList CmdShareList `cmd:"" name:"list" help:"List all shares."`
CmdCreate CmdShareCreate `cmd:"" name:"create" help:"Create a new share."` CmdCreate CmdShareCreate `cmd:"" name:"create" help:"Create a new share."`
CmdDelete CmdShareDelete `cmd:"" name:"delete" help:"Delete a share."` CmdDelete CmdShareDelete `cmd:"" name:"delete" help:"Delete a share."`
CmdAddUser CmdShareAddUser `cmd:"" name:"add-user" help:"Add user to share."` CmdAddUser CmdShareAddUser `cmd:"" name:"add-user" help:"Add user to share."`
CmdAddLogin CmdShareAddLogin `cmd:"" name:"add-login" help:"Add login to share."` CmdAddLogin CmdShareAddLogin `cmd:"" name:"add-login" help:"Add login to share."`
CmdRemoveUser CmdShareRemoveUser `cmd:"" name:"remove-user" help:"Remove user from share."`
CmdRemoveLogin CmdShareRemoveLogin `cmd:"" name:"remove-login" help:"Remove login from share."`
} }
type CmdShareList struct{} type CmdShareList struct{}
@ -142,7 +144,7 @@ func (cmd *CmdShareAddUser) Run(app *app) error {
type CmdShareAddLogin struct { type CmdShareAddLogin struct {
ShareIdentifier ShareIdentifier
Username string `arg:"" name:"username" help:"Username of the user to add the login for."` Username string `arg:"" name:"username" help:"Username of the user to add the login for."`
LoginName string `arg:"" name:"loginname" help:"Name f the login. Must be unique."` LoginName string `arg:"" name:"loginname" help:"Name of the login. Must be unique."`
ReadOnly bool `name:"readonly" help:"If set, the login can only read."` ReadOnly bool `name:"readonly" help:"If set, the login can only read."`
PasswordParam PasswordParam
} }
@ -166,3 +168,24 @@ func (cmd *CmdShareAddLogin) Run(app *app) error {
return app.shareStore.AddLogin(share, cmd.Username, login) return app.shareStore.AddLogin(share, cmd.Username, login)
} }
type CmdShareRemoveUser struct {
ShareIdentifier
Username string `arg:"" name:"username" help:"Username of the user to remove."`
}
func (cmd *CmdShareRemoveUser) Run(app *app) error {
share := Share{UUID: cmd.UUID}
return app.shareStore.RemoveUserFromShare(share, cmd.Username)
}
type CmdShareRemoveLogin struct {
ShareIdentifier
Username string `arg:"" name:"username" help:"Username of the user to remove the login for."`
LoginName string `arg:"" name:"loginname" help:"Name of the login to remove."`
}
func (cmd *CmdShareRemoveLogin) Run(app *app) error {
share := Share{UUID: cmd.UUID}
return app.shareStore.RemoveLogin(share, cmd.Username, cmd.LoginName)
}