service

package
v0.0.0-...-455cc0d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth interface {
	SignUp(ctx context.Context, user domain.User, code uint64, ip string) (domain.Tokens, error)
	SignIn(ctx context.Context, username, password, ip string) (domain.Tokens, error)
	SignOut(ctx context.Context, token, ip string) error
	RefreshTokens(ctx context.Context, token, ip string) (string, error)
	CreateSession(ctx context.Context, id ksuid.KSUID, ip string) (domain.Tokens, error)
}

Auth service interface.

type AuthService

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

Auth service structure.

func (*AuthService) CreateSession

func (s *AuthService) CreateSession(ctx context.Context, id ksuid.KSUID, ip string) (domain.Tokens, error)

Creating a new user session.

func (*AuthService) RefreshTokens

func (s *AuthService) RefreshTokens(ctx context.Context, token, ip string) (string, error)

Refresh user session access token.

func (*AuthService) SignIn

func (s *AuthService) SignIn(ctx context.Context, username, password, ip string) (domain.Tokens, error)

User Sign In.

func (*AuthService) SignOut

func (s *AuthService) SignOut(ctx context.Context, token, ip string) error

User Sign Out.

func (*AuthService) SignUp

func (s *AuthService) SignUp(ctx context.Context, user domain.User, code uint64, ip string) (domain.Tokens, error)

User Sign Up.

type Code

type Code interface {
	CreateVerifyEmailCode(ctx context.Context, email string) error
	VerifyEmailCode(ctx context.Context, email string, input uint64) (bool, error)
}

Code service interface.

type CodeService

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

Code service structure.

func NewCodeService

func NewCodeService(repos redis.Code, email v1.EmailUserServiceClient, cfg *config.CodeConfig) *CodeService

Creating a new code service.

func (*CodeService) CreateVerifyEmailCode

func (s *CodeService) CreateVerifyEmailCode(ctx context.Context, email string) error

Creating a new user verification email code.

func (*CodeService) VerifyEmailCode

func (s *CodeService) VerifyEmailCode(ctx context.Context, email string, input uint64) (bool, error)

Verifying a user verification email code.

type Service

type Service struct {
	User
	Auth
	Code
}

Service structure.

func NewService

func NewService(repos *repository.Repository, config *config.Config, email v1.EmailUserServiceClient) *Service

Creating a new service.

type User

type User interface {
	Create(ctx context.Context, user domain.User) (ksuid.KSUID, error)
	GetByID(ctx context.Context, id ksuid.KSUID) (domain.User, error)
	GetByCreds(ctx context.Context, username, password string) (domain.User, error)
	ForgotPassword(ctx context.Context, password, email string, code uint64) error
	UpdateAvatar(ctx context.Context, id ksuid.KSUID, avatarUrl string) error
}

User service interface.

type UserService

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

User service structure.

func NewUserService

func NewUserService(repos postgres.User, code Code, cfg *config.PasswordConfig) *UserService

Creating a new user service.

func (*UserService) Create

func (s *UserService) Create(ctx context.Context, user domain.User) (ksuid.KSUID, error)

Creating a new user.

func (*UserService) ForgotPassword

func (s *UserService) ForgotPassword(ctx context.Context, password, email string, code uint64) error

Forgot user password.

func (*UserService) GetByCreds

func (s *UserService) GetByCreds(ctx context.Context, username, password string) (domain.User, error)

Getting user by credentials.

func (*UserService) GetByID

func (s *UserService) GetByID(ctx context.Context, id ksuid.KSUID) (domain.User, error)

Getting user by id.

func (*UserService) UpdateAvatar

func (s *UserService) UpdateAvatar(ctx context.Context, id ksuid.KSUID, avatarUrl string) error

Updating user avatar.

Jump to

Keyboard shortcuts

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