service

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

This section is empty.

Variables

View Source
var (
	ErrEmailTaken         = errors.New("email already registered")
	ErrInvalidCredentials = errors.New("invalid credentials")
)

Functions

This section is empty.

Types

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

func (s *AuthService) Authenticate(ctx context.Context, email, password string) (*repo.User, error)

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.

func (*AuthService) Register

func (s *AuthService) Register(ctx context.Context, email, password, name string) (*repo.User, error)

Register creates a new user with a hashed password.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL