Skip to content
edgesync Artifact [fee81bcbe5]
Login

Artifact [fee81bcbe5]

Artifact fee81bcbe5c516e02311be412a97871c757d29009338a1f6c85b6e323fd300fe:


package hub

// User describes a fossil user on the hub repo.
type User struct {
	Login string
	Caps  string
}

// AddUser creates a fossil user. Returns an error if Login is empty or the
// user already exists.
func (h *Hub) AddUser(u User) error { return h.repo.AddUser(u) }

// GetUser returns the user with the given login. Returns an error if no
// such user exists.
func (h *Hub) GetUser(login string) (User, error) { return h.repo.GetUser(login) }

// HasUser reports whether a user with the given login exists.
func (h *Hub) HasUser(login string) bool { return h.repo.HasUser(login) }

// ListUsers returns all users on the hub.
func (h *Hub) ListUsers() ([]User, error) { return h.repo.ListUsers() }

// RemoveUser deletes the user with the given login.
func (h *Hub) RemoveUser(login string) error { return h.repo.RemoveUser(login) }

// SetUserCaps replaces the caps string on an existing user.
func (h *Hub) SetUserCaps(login, caps string) error { return h.repo.SetUserCaps(login, caps) }

// EnsureUser registers a user with the given capabilities if not already
// registered. Idempotent: repeated calls with the same login return nil and
// do not modify the existing row, even when caps differ — existing caps are
// PRESERVED. Callers that need replace-on-conflict semantics should use
// SetUserCaps (or RemoveUser + AddUser) explicitly.
//
// Returns an error only for genuine failures (login empty, underlying repo
// unreachable, etc.). Safe for concurrent in-process callers racing on the
// same login.
func (h *Hub) EnsureUser(login, caps string) error { return h.repo.EnsureUser(login, caps) }