controller

package
v0.0.0-...-9d843bf Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateProfileChangePassworRequest

func ValidateProfileChangePassworRequest(dirtyData *ProfileChangePasswordRequestIDO) error

Types

type GatewayController

type GatewayController interface {
	RegisterBusiness(ctx context.Context, req *gateway_s.RegisterBusinessRequestIDO) error
	RegisterCustomer(ctx context.Context, req *gateway_s.RegisterCustomerRequestIDO) error
	Login(ctx context.Context, email, password string) (*gateway_s.LoginResponseIDO, error)
	GetUserBySessionID(ctx context.Context, sessionID string) (*user_s.User, error)
	RefreshToken(ctx context.Context, value string) (*user_s.User, string, time.Time, string, time.Time, error)
	Verify(ctx context.Context, code string) (*gateway_s.VerifyResponseIDO, error)
	Logout(ctx context.Context) error
	ForgotPassword(ctx context.Context, email string) error
	PasswordReset(ctx context.Context, code string, password string) error
	Profile(ctx context.Context) (*user_s.User, error)
	ProfileUpdate(ctx context.Context, nu *user_s.User) error
	ProfileChangePassword(ctx context.Context, req *ProfileChangePasswordRequestIDO) error
	GenerateOTP(ctx context.Context) (*OTPGenerateResponseIDO, error)
	GenerateOTPAndQRCodePNGImage(ctx context.Context) ([]byte, error)
	VerifyOTP(ctx context.Context, req *VerificationTokenRequestIDO) (*VerificationTokenResponseIDO, error)
	ValidateOTP(ctx context.Context, req *ValidateTokenRequestIDO) (*ValidateTokenResponseIDO, error)
	DisableOTP(ctx context.Context) (*u_d.User, error)
	RecoveryOTP(ctx context.Context, req *RecoveryRequestIDO) (*gateway_s.LoginResponseIDO, error)
}

func NewController

func NewController(
	appCfg *config.Conf,
	loggerp *slog.Logger,
	uuidp uuid.Provider,
	jwtp jwt.Provider,
	kmx kmutex.Provider,
	passwordp password.Provider,
	cache mongodbcache.Cacher,
	client *mongo.Client,
	te templatedemailer.TemplatedEmailer,
	paymentProcessor pm.PaymentProcessor,
	usr_storer user_s.UserStorer,
	org_storer store_s.StoreStorer,
) GatewayController

type GatewayControllerImpl

type GatewayControllerImpl struct {
	Config           *config.Conf
	Logger           *slog.Logger
	UUID             uuid.Provider
	JWT              jwt.Provider
	Kmutex           kmutex.Provider
	Password         password.Provider
	Cache            mongodbcache.Cacher
	DbClient         *mongo.Client
	TemplatedEmailer templatedemailer.TemplatedEmailer
	PaymentProcessor pm.PaymentProcessor
	UserStorer       user_s.UserStorer
	StoreStorer      store_s.StoreStorer
}

func (*GatewayControllerImpl) DisableOTP

func (impl *GatewayControllerImpl) DisableOTP(ctx context.Context) (*u_d.User, error)

DisableOTP function disables 2FA.

func (*GatewayControllerImpl) ForgotPassword

func (impl *GatewayControllerImpl) ForgotPassword(ctx context.Context, email string) error

func (*GatewayControllerImpl) GenerateOTP

GenerateOTP function generates the time-based one-time password (TOTP) secret for the user. The user must use these values to generate a QR to present to the user.

func (*GatewayControllerImpl) GenerateOTPAndQRCodePNGImage

func (impl *GatewayControllerImpl) GenerateOTPAndQRCodePNGImage(ctx context.Context) ([]byte, error)

func (*GatewayControllerImpl) GetUserBySessionID

func (impl *GatewayControllerImpl) GetUserBySessionID(ctx context.Context, sessionID string) (*user_s.User, error)

func (*GatewayControllerImpl) Login

func (impl *GatewayControllerImpl) Login(ctx context.Context, email, password string) (*gateway_s.LoginResponseIDO, error)

func (*GatewayControllerImpl) Logout

func (impl *GatewayControllerImpl) Logout(ctx context.Context) error

func (*GatewayControllerImpl) PasswordReset

func (impl *GatewayControllerImpl) PasswordReset(ctx context.Context, code string, password string) error

func (*GatewayControllerImpl) Profile

func (impl *GatewayControllerImpl) Profile(ctx context.Context) (*user_s.User, error)

func (*GatewayControllerImpl) ProfileChangePassword

func (impl *GatewayControllerImpl) ProfileChangePassword(ctx context.Context, req *ProfileChangePasswordRequestIDO) error

func (*GatewayControllerImpl) ProfileUpdate

func (impl *GatewayControllerImpl) ProfileUpdate(ctx context.Context, nu *user_s.User) error

func (*GatewayControllerImpl) RecoveryOTP

RecoveryOTP function verifies provided `backup code` for the logged in user and disable 2FA plus log user in if successfully verified.

func (*GatewayControllerImpl) RefreshToken

func (impl *GatewayControllerImpl) RefreshToken(ctx context.Context, value string) (*user_s.User, string, time.Time, string, time.Time, error)

func (*GatewayControllerImpl) RegisterBusiness

func (*GatewayControllerImpl) RegisterCustomer

func (*GatewayControllerImpl) ValidateOTP

ValidateOTP function verifies provided token from the third-party authenticator app. The purpose of this function is enable the loggin for 2FA.

func (*GatewayControllerImpl) Verify

func (*GatewayControllerImpl) VerifyOTP

VerifyOTP function verifies provided token from the third-party authenticator app. The purpose of this function is to finish the otp setup.

type OTPGenerateResponseIDO

type OTPGenerateResponseIDO struct {
	Base32      string `json:"base32"`
	OTPAuthURL  string `json:"otpauth_url"`
	AccountName string `json:"account_name"`
}

type ProfileChangePasswordRequestIDO

type ProfileChangePasswordRequestIDO struct {
	OldPassword         string `json:"old_password"`
	NewPassword         string `json:"new_password"`
	NewPasswordRepeated string `json:"new_password_repeated"`
}

type RecoveryRequestIDO

type RecoveryRequestIDO struct {
	BackupCode string `json:"backup_code"`
}

type ValidateTokenRequestIDO

type ValidateTokenRequestIDO struct {
	Token string `json:"token"`
}

type ValidateTokenResponseIDO

type ValidateTokenResponseIDO struct {
	User *u_d.User `json:"user"`
}

type VerificationTokenRequestIDO

type VerificationTokenRequestIDO struct {
	VerificationToken string `json:"verification_token"`
}

type VerificationTokenResponseIDO

type VerificationTokenResponseIDO struct {
	User          *u_d.User `json:"user"`
	OTPBackupCode string    `json:"otp_backup_code"`
}

Jump to

Keyboard shortcuts

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