accounts

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0, BSD-3-Clause, ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPassword = errors.New("invalid password")
	ErrUnknownUsername = errors.New("unknown user")
)

Enumeration of possible errors that can be returned from authenticate.

Functions

This section is empty.

Types

type Options

type Options struct {
	Database dbmodels.DBTX
	Hasher   hash.Hasher
}

Options specifies options for account services.

type Service

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

Service implements account services using the database.

func NewService

func NewService(opts Options) *Service

NewService creates new account services using the database.

func (*Service) AddCharacter

func (s *Service) AddCharacter(ctx context.Context, playerID int64, data pangya.PlayerCharacterData) error

AddCharacter adds a character for a given player.

func (*Service) AddSession

func (s *Service) AddSession(ctx context.Context, playerID int64, address string) (dbmodels.Session, error)

AddSession adds a new session for a player.

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, username, password string) (dbmodels.Player, error)

Authenticate authenticates a user using the database.

func (*Service) DeleteExpiredSessions

func (s *Service) DeleteExpiredSessions(ctx context.Context) error

DeleteExpiredSessions deletes sessions that have expired.

func (*Service) GetCharacters

func (s *Service) GetCharacters(ctx context.Context, playerID int64) ([]pangya.PlayerCharacterData, error)

GetCharacters returns the characters for a given player.

func (*Service) GetPlayer

func (s *Service) GetPlayer(ctx context.Context, playerID int64) (dbmodels.Player, error)

func (*Service) GetSession

func (s *Service) GetSession(ctx context.Context, sessionID int64) (dbmodels.Session, error)

GetSession gets a session by its ID.

func (*Service) GetSessionByKey

func (s *Service) GetSessionByKey(ctx context.Context, sessionKey string) (dbmodels.Session, error)

GetSessionByKey gets a session by its session key.

func (*Service) HasCharacters

func (s *Service) HasCharacters(ctx context.Context, playerID int64) (bool, error)

HasCharacters returns whether or not the player has characters.

func (*Service) Register

func (s *Service) Register(ctx context.Context, username, password string) (dbmodels.Player, error)

func (*Service) SetNickname

func (s *Service) SetNickname(ctx context.Context, playerID int64, nickname string) (dbmodels.Player, error)

SetNickname sets the player's nickname.

func (*Service) UpdateSessionExpiry

func (s *Service) UpdateSessionExpiry(ctx context.Context, sessionID int64) (dbmodels.Session, error)

UpdateSessionExpiry bumps the session expiry value for a session.

Jump to

Keyboard shortcuts

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