controller

package
v0.0.0-...-75c6f16 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 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 DashboardResponseIDO

type DashboardResponseIDO struct {
	ClientsCount    int64 `json:"clients_count"`
	AssociatesCount int64 `json:"associates_count"`
	JobsCount       int64 `json:"jobs_count"`
	TasksCount      int64 `json:"tasks_count"`
}

type ExecutiveVisitsTenantRequest

type ExecutiveVisitsTenantRequest struct {
	TenantID primitive.ObjectID `json:"tenant_id,omitempty"`
}

type GatewayController

type GatewayController interface {
	UserRegister(ctx context.Context, req *UserRegisterRequestIDO) (*gateway_s.LoginResponseIDO, 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)
	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
	ExecutiveVisitsTenant(ctx context.Context, req *ExecutiveVisitsTenantRequest) error
	Dashboard(ctx context.Context) (*DashboardResponseIDO, 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)
}

func NewController

func NewController(
	appCfg *config.Conf,
	loggerp *slog.Logger,
	uuidp uuid.Provider,
	jwtp jwt.Provider,
	passwordp password.Provider,
	kmux kmutex.Provider,
	cache mongodbcache.Cacher,
	te templatedemailer.TemplatedEmailer,
	client *mongo.Client,
	usr_storer user_s.UserStorer,
	org_storer tenant_s.TenantStorer,
	howhear_s howhear_s.HowHearAboutUsItemStorer,
) GatewayController

type GatewayControllerImpl

type GatewayControllerImpl struct {
	Config                   *config.Conf
	Logger                   *slog.Logger
	UUID                     uuid.Provider
	JWT                      jwt.Provider
	Password                 password.Provider
	Kmutex                   kmutex.Provider
	DbClient                 *mongo.Client
	Cache                    mongodbcache.Cacher
	TemplatedEmailer         templatedemailer.TemplatedEmailer
	UserStorer               user_s.UserStorer
	TenantStorer             tenant_s.TenantStorer
	HowHearAboutUsItemStorer howhear_s.HowHearAboutUsItemStorer
}

func (*GatewayControllerImpl) Dashboard

func (*GatewayControllerImpl) DisableOTP

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

DisableOTP function disables 2FA.

func (*GatewayControllerImpl) ExecutiveVisitsTenant

func (impl *GatewayControllerImpl) ExecutiveVisitsTenant(ctx context.Context, req *ExecutiveVisitsTenantRequest) error

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) RefreshToken

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

func (*GatewayControllerImpl) UserRegister

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) 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"`
}

type ProfileChangePasswordRequestIDO

type ProfileChangePasswordRequestIDO struct {
	OldPassword      string `json:"old_password"`
	Password         string `json:"password"`
	PasswordRepeated string `json:"password_repeated"`
}

type UserRegisterRequestIDO

type UserRegisterRequestIDO struct {
	TenantID                    primitive.ObjectID `json:"tenant_id,omitempty"`
	FirstName                   string             `json:"first_name"`
	LastName                    string             `json:"last_name"`
	Email                       string             `json:"email"`
	EmailRepeated               string             `json:"email_repeated"`
	IsOkToEmail                 bool               `json:"is_ok_to_email"`
	Password                    string             `json:"password"`
	PasswordRepeated            string             `json:"password_repeated"`
	Phone                       string             `json:"phone,omitempty"`
	PhoneType                   int8               `json:"phone_type"`
	PhoneExtension              string             `json:"phone_extension"`
	IsOkToText                  bool               `json:"is_ok_to_text"`
	OtherPhone                  string             `json:"other_phone"`
	OtherPhoneExtension         string             `json:"other_phone_extension"`
	OtherPhoneType              int8               `json:"other_phone_type"`
	Country                     string             `json:"country,omitempty"`
	Region                      string             `json:"region,omitempty"`
	City                        string             `json:"city,omitempty"`
	PostalCode                  string             `json:"postal_code,omitempty"`
	AddressLine1                string             `json:"address_line_1,omitempty"`
	AddressLine2                string             `json:"address_line_2,omitempty"`
	HowDidYouHearAboutUsID      primitive.ObjectID `bson:"how_did_you_hear_about_us_id" json:"how_did_you_hear_about_us_id,omitempty"`
	HowDidYouHearAboutUsText    string             `bson:"how_did_you_hear_about_us_text" json:"how_did_you_hear_about_us_text,omitempty"`
	IsHowDidYouHearAboutUsOther bool               `bson:"is_how_did_you_hear_about_us_other" json:"is_how_did_you_hear_about_us_other,omitempty"`
	HowDidYouHearAboutUsOther   string             `bson:"how_did_you_hear_about_us_other" json:"how_did_you_hear_about_us_other,omitempty"`
	AgreeTOS                    bool               `bson:"agree_tos" json:"agree_tos,omitempty"`
	AgreePromotionsEmail        bool               `json:"agree_promotions_email,omitempty"`
	AgreeWaiver                 bool               `bson:"agree_waiver" json:"agree_waiver,omitempty"`
	HasShippingAddress          bool               `bson:"has_shipping_address" json:"has_shipping_address,omitempty"`
	ShippingName                string             `bson:"shipping_name" json:"shipping_name,omitempty"`
	ShippingPhone               string             `bson:"shipping_phone" json:"shipping_phone,omitempty"`
	ShippingCountry             string             `bson:"shipping_country" json:"shipping_country,omitempty"`
	ShippingRegion              string             `bson:"shipping_region" json:"shipping_region,omitempty"`
	ShippingCity                string             `bson:"shipping_city" json:"shipping_city,omitempty"`
	ShippingPostalCode          string             `bson:"shipping_postal_code" json:"shipping_postal_code,omitempty"`
	ShippingAddressLine1        string             `bson:"shipping_address_line1" json:"shipping_address_line1,omitempty"`
	ShippingAddressLine2        string             `bson:"shipping_address_line2" json:"shipping_address_line2,omitempty"`
	HasCouponPromotionalCode    int8               `json:"has_coupon_promotional_code,omitempty"`
	CouponPromotionalCode       string             `bson:"coupon_promotional_code" json:"coupon_promotional_code,omitempty"`
	BirthDate                   time.Time          `json:"birth_date"`
	JoinDate                    time.Time          `json:"join_date"`
	Gender                      int8               `bson:"gender" json:"gender"`
	GenderOther                 string             `bson:"gender_other" json:"gender_other"`
}

type UserRegisterResponseIDO

type UserRegisterResponseIDO struct {
	User                   *user_s.User `json:"user"`
	AccessToken            string       `json:"access_token"`
	AccessTokenExpiryTime  time.Time    `json:"access_token_expiry_time"`
	RefreshToken           string       `json:"refresh_token"`
	RefreshTokenExpiryTime time.Time    `json:"refresh_token_expiry_time"`
}

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"`
}

Jump to

Keyboard shortcuts

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