Documentation
¶
Overview ¶
Package service holds business logic that outlives any one HTTP handler. Today that is authentication: registration, login and the password rules, kept here so the web and API layers apply the same ones.
Index ¶
Constants ¶
const ( SettingUpgradeLatest = "upgrade_latest" SettingUpgradeCheckedAt = "upgrade_checked_at" SettingUpgradePrevious = "upgrade_previous_image" SettingUpgradeArchive = "upgrade_archive" )
Settings the upgrade writes, read back by the update page.
Variables ¶
var ( ErrEmailTaken = errors.New("email already registered") ErrInvalidCredentials = errors.New("invalid credentials") )
var ErrUpgradeRunning = errors.New("upgrade already running")
Functions ¶
This section is empty.
Types ¶
type AdminService ¶ added in v0.1.1
type AdminService struct {
// contains filtered or unexported fields
}
AdminService is installation-wide operations an admin triggers from the panel. Upgrade is the first; maintenance and the manual panel backup belong here too.
func NewAdminService ¶ added in v0.1.1
func NewAdminService(store repo.Store, rt *runtime.Runtime, clus *cluster.Cluster, backups *backup.Service, dataDir, version string) *AdminService
NewAdminService creates a new admin service.
func (*AdminService) Available ¶ added in v0.1.1
func (s *AdminService) Available(ctx context.Context) (string, bool)
Available returns the cached latest release when it is newer than this build.
func (*AdminService) CheckUpgrade ¶ added in v0.1.1
func (s *AdminService) CheckUpgrade(ctx context.Context) (string, error)
CheckUpgrade asks GitHub for the latest release and caches it in settings.
func (*AdminService) Upgradable ¶ added in v0.1.1
func (s *AdminService) Upgradable() bool
Upgradable is false for dev builds. They have no release to compare against and no published image of their own to roll back to.
func (*AdminService) Upgrade ¶ added in v0.1.1
func (s *AdminService) Upgrade(ctx context.Context, tag string) error
Upgrade moves the panel to the release tag: pull both images, retag the relay, write a restorable archive, then point the panel's own service at the new image. Swarm replaces this task, and the new panel's boot rolls the node agents to the same build.
Everything that can fail runs before the service update. A new task that does not stay up is rolled back by swarm; the data is not, which is what the archive is for.
func (*AdminService) Version ¶ added in v0.1.1
func (s *AdminService) Version() string
Version is the running build: a release tag like v0.1.1, or "dev".
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService handles authentication logic.
func NewAuthService ¶
func NewAuthService(store repo.Store) *AuthService
NewAuthService creates a new auth service.
func (*AuthService) Authenticate ¶
Authenticate verifies credentials and returns the user.
func (*AuthService) ChangePassword ¶
func (s *AuthService) ChangePassword(ctx context.Context, userID, current, next string) error
ChangePassword swaps a user's password after verifying the current one. The current-password check is what stops a stolen session from locking the real owner out of their own account.