service

package
v0.0.0-...-cfe4a27 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeSceneRegister      = "register"
	CodeSceneResetPassword = "reset_password"
)

Variables

View Source
var (
	ErrInvalidInput        = errors.New("invalid input")
	ErrEmailExists         = errors.New("email already exists")
	ErrAccountNotFound     = errors.New("account not found")
	ErrAccountDisabled     = errors.New("account disabled")
	ErrInvalidCredentials  = errors.New("invalid email or password")
	ErrTooManyRequests     = errors.New("too many requests")
	ErrInvalidCode         = errors.New("invalid verification code")
	ErrCodeExpired         = errors.New("verification code expired")
	ErrCodeTooManyAttempts = errors.New("too many verification attempts")
	ErrUnauthorized        = errors.New("unauthorized")
	ErrSaveNotFound        = errors.New("player data not found")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID          uint64     `json:"id"`
	Email       string     `json:"email"`
	Nickname    string     `json:"nickname"`
	Status      int        `json:"status"`
	LoginCount  uint64     `json:"login_count"`
	LastLoginAt *time.Time `json:"last_login_at,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

func AuthenticateToken

func AuthenticateToken(ctx context.Context, token string) (*Account, error)

func GetAccountByID

func GetAccountByID(ctx context.Context, accountID uint64) (*Account, error)

type AuthResult

type AuthResult struct {
	Account Account   `json:"account"`
	Token   AuthToken `json:"token"`
}

type AuthService

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

func NewAuthService

func NewAuthService(sender mailer.Sender) *AuthService

func (*AuthService) Login

func (s *AuthService) Login(ctx context.Context, email string, password string) (*AuthResult, error)

func (*AuthService) Logout

func (s *AuthService) Logout(_ context.Context, token string) error

func (*AuthService) Register

func (s *AuthService) Register(ctx context.Context, email string, password string, nickname string, code string) (*AuthResult, error)

func (*AuthService) ResetPassword

func (s *AuthService) ResetPassword(ctx context.Context, email string, code string, newPassword string) (*AuthResult, error)

func (*AuthService) SendEmailCode

func (s *AuthService) SendEmailCode(ctx context.Context, email string, scene string) error

type AuthToken

type AuthToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int64  `json:"expires_in"`
}

type PlayerData

type PlayerData struct {
	ID        uint64          `json:"id"`
	AccountID uint64          `json:"account_id"`
	GameKey   string          `json:"game_key"`
	SlotKey   string          `json:"slot_key"`
	Data      json.RawMessage `json:"data"`
	Version   uint64          `json:"version"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
}

type PlayerDataService

type PlayerDataService struct{}

func NewPlayerDataService

func NewPlayerDataService() *PlayerDataService

func (*PlayerDataService) Delete

func (s *PlayerDataService) Delete(ctx context.Context, accountID uint64, id uint64) error

func (*PlayerDataService) Get

func (s *PlayerDataService) Get(ctx context.Context, accountID uint64, id uint64) (*PlayerData, error)

func (*PlayerDataService) List

func (s *PlayerDataService) List(ctx context.Context, accountID uint64, gameKey string) ([]PlayerDataSummary, error)

func (*PlayerDataService) Update

func (s *PlayerDataService) Update(ctx context.Context, accountID uint64, id uint64, data json.RawMessage) (*PlayerData, error)

func (*PlayerDataService) Upsert

func (s *PlayerDataService) Upsert(ctx context.Context, accountID uint64, gameKey string, slotKey string, data json.RawMessage) (*PlayerData, error)

type PlayerDataSummary

type PlayerDataSummary struct {
	ID        uint64    `json:"id"`
	GameKey   string    `json:"game_key"`
	SlotKey   string    `json:"slot_key"`
	Version   uint64    `json:"version"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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