1package backend23import (4 "context"56 "github.com/charmbracelet/soft-serve/pkg/access"7 "github.com/charmbracelet/soft-serve/pkg/db"8)910// AllowKeyless returns whether or not keyless access is allowed.11//12// It implements backend.Backend.13func (b *Backend) AllowKeyless(ctx context.Context) bool {14 var allow bool15 if err := b.db.TransactionContext(ctx, func(tx *db.Tx) error {16 var err error17 allow, err = b.store.GetAllowKeylessAccess(ctx, tx)18 return err19 }); err != nil {20 return false21 }2223 return allow24}2526// SetAllowKeyless sets whether or not keyless access is allowed.27//28// It implements backend.Backend.29func (b *Backend) SetAllowKeyless(ctx context.Context, allow bool) error {30 return b.db.TransactionContext(ctx, func(tx *db.Tx) error {31 return b.store.SetAllowKeylessAccess(ctx, tx, allow)32 })33}3435// AnonAccess returns the level of anonymous access.36//37// It implements backend.Backend.38func (b *Backend) AnonAccess(ctx context.Context) access.AccessLevel {39 var level access.AccessLevel40 if err := b.db.TransactionContext(ctx, func(tx *db.Tx) error {41 var err error42 level, err = b.store.GetAnonAccess(ctx, tx)43 return err44 }); err != nil {45 return access.NoAccess46 }4748 return level49}5051// SetAnonAccess sets the level of anonymous access.52//53// It implements backend.Backend.54func (b *Backend) SetAnonAccess(ctx context.Context, level access.AccessLevel) error {55 return b.db.TransactionContext(ctx, func(tx *db.Tx) error {56 return b.store.SetAnonAccess(ctx, tx, level)57 })58}