account

package
v0.0.0-...-0f1690e Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccountRepository

func NewAccountRepository(accountsCollection *mongo.Collection) *accountRepository

func NewAccountSessionTxn

func NewAccountSessionTxn(client *mongo.Client, accountRepository *accountRepository, sessionRepository *sessionRepository) *accountSessionTxn

func NewGeneralInMemoryStorage

func NewGeneralInMemoryStorage(client *redis.Client) *generalInMemoryStorage

func NewSessionRepository

func NewSessionRepository(client *mongo.Client, sessionsCollection *mongo.Collection) *sessionRepository

Types

type DBModel

type DBModel struct {
	ID                primitive.Binary    `bson:"_id"`
	FirstName         string              `bson:"first_name"`
	LastName          string              `bson:"last_name"`
	Nickname          string              `bson:"nickname"`
	Email             string              `bson:"email"`
	BirthDate         time.Time           `bson:"birth_date"`
	CurrentCountry    string              `bson:"current_country"`
	CreatedAt         primitive.Timestamp `bson:"created_at"`
	UpdatedAt         primitive.Timestamp `bson:"updated_at"`
	EncryptedPassword primitive.Binary    `bson:"encrypted_password"`
}

type Entity

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

func NewEntity

func NewEntity(nickname, email string) (*Entity, error)

func (*Entity) GetBirthDate

func (e *Entity) GetBirthDate() time.Time

func (*Entity) GetCurrentCountry

func (e *Entity) GetCurrentCountry() string

func (*Entity) GetEmail

func (e *Entity) GetEmail() string

func (*Entity) GetFirstName

func (e *Entity) GetFirstName() string

func (*Entity) GetID

func (e *Entity) GetID() string

func (*Entity) GetLastName

func (e *Entity) GetLastName() string

func (*Entity) GetNickname

func (e *Entity) GetNickname() string

func (*Entity) RegisterUpdate

func (e *Entity) RegisterUpdate()

func (*Entity) SetBirthDate

func (e *Entity) SetBirthDate(val time.Time)

func (*Entity) SetCurrentCountry

func (e *Entity) SetCurrentCountry(val string)

func (*Entity) SetFirstName

func (e *Entity) SetFirstName(val string)

func (*Entity) SetLastName

func (e *Entity) SetLastName(val string)

type HandleSessionsOverflowDTO

type HandleSessionsOverflowDTO struct {
	Email     string
	VerifCode string
	IP        string
	PipeID    string
}

type PasswordResetRequestDTO

type PasswordResetRequestDTO struct {
	CaptchaID             string
	ProvidedCaptchaAnswer string
	Email                 string
}

type PerformPasswordResetDTO

type PerformPasswordResetDTO struct {
	VerifCode   string
	Email       string
	NewPassword string
}

type PrepareSessOverflowPipeDTO

type PrepareSessOverflowPipeDTO struct {
	IP        string
	AccountID string
	Email     string
}

type SendVerifCodeToCleanSessionsDTO

type SendVerifCodeToCleanSessionsDTO struct {
	IP     string
	Email  string
	PipeID string
}

type Service

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

func NewService

func NewService(
	emailManager emailManager,
	accountRepository *accountRepository,
	sessionRepository *sessionRepository,
	accountSessionTxn *accountSessionTxn,
	inMemoryStorage *generalInMemoryStorage,
) *Service

func (*Service) CreatePasswordResetRequest

func (s *Service) CreatePasswordResetRequest(ctx context.Context, dto *PasswordResetRequestDTO) error

CreatePasswordResetRequest TODO: implement security mechanism -> - Sending verif code ->->->[Ban for 30 min BY IP]

func (*Service) GenerateCaptcha

func (s *Service) GenerateCaptcha(ctx context.Context, captchaType int) (string, string, error)

func (*Service) GetAccessToken

func (s *Service) GetAccessToken(ctx context.Context, refreshToken string, keyReader auth.KeyReader) (string, error)

func (*Service) GetAccount

func (s *Service) GetAccount(ctx context.Context, nickname string) (*Entity, error)

func (*Service) HandleSessionsOverflow

func (s *Service) HandleSessionsOverflow(ctx context.Context,
	dto *HandleSessionsOverflowDTO, keyReader auth.KeyReader) (string, string, error)

func (*Service) IsAvailableEmail

func (s *Service) IsAvailableEmail(ctx context.Context, email string) (bool, error)

IsAvailableEmail TODO: check pipeID(from sign up)

func (*Service) IsAvailableNickname

func (s *Service) IsAvailableNickname(ctx context.Context, nickname string) (bool, error)

IsAvailableNickname TODO: check pipeID(from sign up)

func (*Service) IsSignInCaptcha

func (s *Service) IsSignInCaptcha(ctx context.Context, email string) (bool, error)

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, refreshToken string, keyReader auth.KeyReader) error

func (*Service) PerformPasswordReset

func (s *Service) PerformPasswordReset(ctx context.Context, dto *PerformPasswordResetDTO) error

func (*Service) ResendVerifCodeForSignUp

func (s *Service) ResendVerifCodeForSignUp(ctx context.Context, pipeID string) error

func (*Service) SendVerifCodeForPasswordUpdate

func (s *Service) SendVerifCodeForPasswordUpdate(ctx context.Context, accountID string) error

func (*Service) SendVerifCodeToCleanSessions

func (s *Service) SendVerifCodeToCleanSessions(ctx context.Context, dto *SendVerifCodeToCleanSessionsDTO) error

func (*Service) SignIn

func (s *Service) SignIn(ctx context.Context, dto *SignInDTO, keyReader auth.KeyReader) (*SignInResultDTO, error)

func (*Service) SignUp

func (s *Service) SignUp(ctx context.Context, dto *SignUpDTO) error

func (*Service) StartSignUpPipe

func (s *Service) StartSignUpPipe(ctx context.Context, dto *StartSignUpPipeDTO) (string, error)

func (*Service) UpdateAccount

func (s *Service) UpdateAccount(ctx context.Context, dto *UpdateAccountDTO) error

func (*Service) UpdatePassword

func (s *Service) UpdatePassword(ctx context.Context, dto *UpdatePasswordDTO, keyReader auth.KeyReader) (string, error)

type Session

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

func NewSession

func NewSession(accountID string) (*Session, error)

func (*Session) GetSessionID

func (s *Session) GetSessionID() string

type SessionDBModel

type SessionDBModel struct {
	ID        primitive.Binary `bson:"_id"`
	AccountID primitive.Binary `bson:"account_id"`
}

type SignInDTO

type SignInDTO struct {
	CaptchaID             string
	ProvidedCaptchaAnswer string
	Email                 string
	Password              string
	IP                    string
}

type SignInResultDTO

type SignInResultDTO struct {
	AccessToken            string
	RefreshToken           string
	SessionsOverflowPipeID string
}

type SignUpDTO

type SignUpDTO struct {
	ProvidedVerifCode string
	PipeID            string
}

type StartSignUpPipeDTO

type StartSignUpPipeDTO struct {
	CaptchaID             string
	ProvidedCaptchaAnswer string
	Email                 string
	Nickname              string
	Password              string
}

type UpdateAccountDTO

type UpdateAccountDTO struct {
	ID             string
	BirthDate      time.Time
	CurrentCountry string
	FirstName      string
	LastName       string
}

type UpdatePasswordDTO

type UpdatePasswordDTO struct {
	RefreshToken      string
	NewPassword       string
	FeelLikeGetHacked bool
	ProvidedVerifCode string
}

Jump to

Keyboard shortcuts

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