Files
kopia/cli/command_user_delete.go
Jarek Kowalski 5d07237156 Added support for user authentication using user profiles stored in the repository (#809)
* user: added user profile (username&password for authentication) and CRUD methods
* manifest: helpers for disambiguating manifest entries
* authn: added repository-based user authenticator
* cli: added commands to manipulate user accounts and passwords
* cli: added --allow-repository-users option to 'server start'
* Update cli/command_user_info.go

Co-authored-by: Julio López <julio+gh@kasten.io>
* Always return false when the user is not found.
2021-02-03 22:04:05 -08:00

31 lines
673 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/internal/user"
"github.com/kopia/kopia/repo"
)
var (
userDeleteCommand = userCommands.Command("delete", "Delete user")
userDeleteName = userDeleteCommand.Arg("username", "The username to delete.").Required().String()
)
func runUserDelete(ctx context.Context, rep repo.RepositoryWriter) error {
err := user.DeleteUserProfile(ctx, rep, *userDeleteName)
if err != nil {
return errors.Wrap(err, "error deleting user profile")
}
log(ctx).Infof("User %q deleted.", *userDeleteName)
return nil
}
func init() {
userDeleteCommand.Action(repositoryWriterAction(runUserDelete))
}