accountsvc

package
v0.0.0-...-a66760f Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAccessToken

func GenerateAccessToken(accountID int64) (string, error)

func GetClaims

func GetClaims(r *http.Request) (claims accountmodel.Claims, err error)

GetClaims retrieves and validates JWT claims from the token, using an in-memory cache

func ValidateAccessToken

func ValidateAccessToken(tokenStr string) (claims accountmodel.Claims, err error)

Types

type GetUserParams

type GetUserParams struct {
	Account  accountmodel.AuthenticatedAccount
	ID       *int64
	Username *string
	Email    *string
	Phone    *string
}

type LoginUserParams

type LoginUserParams struct {
	ID       *int64
	Username *string
	Email    *string
	Phone    *string
	Password string
}

type LoginUserResult

type LoginUserResult struct {
	Token   string                   `json:"token"`
	Account accountmodel.AccountBase `json:"account"`
}

type RegisterUserParams

type RegisterUserParams struct {
	FirstName string
	LastName  string
	Username  string
	Password  string
	Email     *string
	Phone     *string
}

type RegisterUserResult

type RegisterUserResult struct {
	Token   string                   `json:"token"`
	Account accountmodel.AccountUser `json:"account"`
}

type Service

type Service interface {
	UpdateAccount(ctx context.Context, params UpdateAccountParams) (accountmodel.AccountBase, error)
	UpdateUser(ctx context.Context, params UpdateUserParams) (accountmodel.AccountUser, error)
	GetUser(ctx context.Context, params GetUserParams) (accountmodel.AccountUser, error)
	LoginUser(ctx context.Context, params LoginUserParams) (LoginUserResult, error)
	RegisterUser(ctx context.Context, params RegisterUserParams) (RegisterUserResult, error)
}

func NewService

func NewService(storage *accountstorage.Storage) Service

type ServiceImpl

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

func (*ServiceImpl) GetUser

func (*ServiceImpl) LoginUser

func (s *ServiceImpl) LoginUser(ctx context.Context, params LoginUserParams) (LoginUserResult, error)

func (*ServiceImpl) RegisterUser

func (s *ServiceImpl) RegisterUser(ctx context.Context, params RegisterUserParams) (res RegisterUserResult, err error)

func (*ServiceImpl) UpdateAccount

func (s *ServiceImpl) UpdateAccount(ctx context.Context, params UpdateAccountParams) (accountmodel.AccountBase, error)

func (*ServiceImpl) UpdateUser

type UpdateAccountParams

type UpdateAccountParams struct {
	Account         accountmodel.AuthenticatedAccount
	CurrentPassword string
	Username        *string
	NewPassword     *string
}

type UpdateUserParams

type UpdateUserParams struct {
	ID          int64
	FirstName   *string
	LastName    *string
	Email       *string
	NullEmail   bool
	Phone       *string
	NullPhone   bool
	Company     *string
	NullCompany bool
	Address     *string
	NullAddress bool
}

Jump to

Keyboard shortcuts

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