~bigbes/sr-ht-spec

ref: a4d8cc52e917cf1db07c876e8b36654dcf28741b sr-ht-spec/service/user.go -rw-r--r-- 581 bytes
a4d8cc52 — Eugene Blikh authn: remove the local agent-token plane 10 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package service

import (
	"context"
	"fmt"
)

// EnsureOwnerUser seeds the owner's user row (username = the configured
// owner-name) and caches its id for the webhook auth bridge. Call once at
// startup.
func (s *Service) EnsureOwnerUser(ctx context.Context) error {
	id, err := s.store.EnsureUser(ctx, s.cfg.Instance.OwnerName)
	if err != nil {
		return fmt.Errorf("service: ensure owner user: %w", err)
	}
	s.ownerUserID = id
	return nil
}

// OwnerUserID is the owner user row id, 0 until EnsureOwnerUser has run.
func (s *Service) OwnerUserID() int { return s.ownerUserID }