auth

package
v0.0.0-...-ba52af2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Errors
	ErrUserNotFound       = errors.New("user not found")
	ErrInvalidCredentials = errors.New("invalid email or password")
	ErrUserExists         = errors.New("user already exists")
)

Functions

func CheckPassword

func CheckPassword(password, hash string) error

func ClearUserSession

func ClearUserSession(c buffalo.Context)

func GetUserSession

func GetUserSession(c buffalo.Context) string

func HashPassword

func HashPassword(password string) (string, error)

Password helpers - needed for "logged in as valid user" step

func LoginFormHandler

func LoginFormHandler(c buffalo.Context) error

LoginFormHandler serves the login form - ONLY what the feature asks for

func LoginHandler

func LoginHandler(c buffalo.Context) error

LoginHandler processes login - ONLY what the feature asks for

func LogoutHandler

func LogoutHandler(c buffalo.Context) error

LogoutHandler processes logout - ONLY what the feature asks for

func RegisterAuthJobs

func RegisterAuthJobs(mux interface{}, store interface{})

RegisterAuthJobs is a stub to satisfy compilation - NOT IMPLEMENTED per BDD The feature file doesn't specify background jobs

func RequireLogin

func RequireLogin(next buffalo.Handler) buffalo.Handler

RequireLogin middleware - feature asks for this specifically

func SetUserSession

func SetUserSession(c buffalo.Context, userID string)

Session helpers - minimal implementation for what tests need

func UseStore

func UseStore(store UserStore)

UseStore sets the global user store

Types

type ExtendedUserStore

type ExtendedUserStore interface {
	UserStore

	// Minimal stub methods to satisfy compilation
	ByID(ctx context.Context, id string) (*User, error)
	IncrementFailedLoginAttempts(ctx context.Context, email string) error
	ResetFailedLoginAttempts(ctx context.Context, email string) error
	CleanupSessions(ctx context.Context, maxAge, maxInactivity time.Duration) (int, error)
}

ExtendedUserStore is a stub interface to satisfy jobs package compilation This is NOT part of the BDD feature requirements and should be removed once jobs package is properly tested with BDD-first approach

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

Simple in-memory store for testing - ONLY what's needed

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) ByEmail

func (m *MemoryStore) ByEmail(ctx context.Context, email string) (*User, error)

func (*MemoryStore) ByID

func (m *MemoryStore) ByID(ctx context.Context, id string) (*User, error)

func (*MemoryStore) CleanupSessions

func (m *MemoryStore) CleanupSessions(ctx context.Context, maxAge, maxInactivity time.Duration) (int, error)

func (*MemoryStore) Create

func (m *MemoryStore) Create(ctx context.Context, user *User) error

func (*MemoryStore) ExistsEmail

func (m *MemoryStore) ExistsEmail(ctx context.Context, email string) (bool, error)

func (*MemoryStore) IncrementFailedLoginAttempts

func (m *MemoryStore) IncrementFailedLoginAttempts(ctx context.Context, email string) error

Make MemoryStore implement ExtendedUserStore minimally

func (*MemoryStore) ResetFailedLoginAttempts

func (m *MemoryStore) ResetFailedLoginAttempts(ctx context.Context, email string) error

func (*MemoryStore) UpdatePassword

func (m *MemoryStore) UpdatePassword(ctx context.Context, id string, passwordDigest string) error

type User

type User struct {
	ID             string `json:"id" db:"id"`
	Email          string `json:"email" db:"email"`
	DisplayName    string `json:"name" db:"name"`
	PasswordDigest string `json:"-" db:"password_digest"`
	IsActive       bool   `json:"is_active" db:"is_active"`
}

User represents a minimal user for authentication

func CurrentUser

func CurrentUser(c buffalo.Context) *User

CurrentUser gets the current user from context - feature asks for this

func (*User) Name

func (u *User) Name() string

Name returns the user's name as a method for compatibility

type UserStore

type UserStore interface {
	Create(ctx context.Context, user *User) error
	ByEmail(ctx context.Context, email string) (*User, error)
	ByID(ctx context.Context, id string) (*User, error)
	UpdatePassword(ctx context.Context, id string, passwordDigest string) error
	ExistsEmail(ctx context.Context, email string) (bool, error)
}

UserStore defines the minimal interface for user storage

func GetStore

func GetStore() UserStore

GetStore returns the current global store

func NewSQLStore

func NewSQLStore(db interface{}, dialect string) UserStore

NewSQLStore is a stub to satisfy compilation - NOT IMPLEMENTED per BDD The feature file doesn't specify SQL storage, so this returns memory store

Jump to

Keyboard shortcuts

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