user

package
v0.0.0-...-f06a132 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailVerificationTokenLength = 16
)
View Source
const (
	TRIAL_DURATION_DAYS = 14
)

Variables

This section is empty.

Functions

func NewSendVerificationEmailErr

func NewSendVerificationEmailErr(errType SendVerificationEmailErrType, msg string) error

Types

type AccountType

type AccountType int
const (
	TrialAccount AccountType = iota
	BasicAccount
	TestAccount // Account with no expiry (remove after beta test)
)

func (AccountType) String

func (a AccountType) String() string

type SendVerificationEmailErrType

type SendVerificationEmailErrType int
const (
	ResendDisabled SendVerificationEmailErrType = iota
	UserVerified
)

type SendVerificationEmailError

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

func (SendVerificationEmailError) ErrType

func (SendVerificationEmailError) Error

type User

type User struct {
	gorm.Model
	Uuid              string
	Name              string
	Email             string
	Password          string
	AccountType       AccountType
	LicenseExpiry     time.Time
	IsVerified        bool
	VerificationToken string
}

type UserService

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

func InitUserService

func InitUserService(db *gorm.DB, emailService *email.EmailService) *UserService

func (*UserService) CheckLicenseValid

func (u *UserService) CheckLicenseValid(user *User) bool

func (*UserService) CreateUser

func (u *UserService) CreateUser(ctx context.Context, name string,
	email string, password string) (*User, error)

Creates a user. Will hash provided password before storing into DB

func (*UserService) GetUserByEmail

func (u *UserService) GetUserByEmail(ctx context.Context, email string) (*User, error)

func (*UserService) GetUserById

func (u *UserService) GetUserById(ctx context.Context, id uint) (*User, error)

func (*UserService) GetUserByUuid

func (u *UserService) GetUserByUuid(ctx context.Context, uuid string) (*User, error)

Get user by UUID

func (*UserService) ResendVerificationEmail

func (u *UserService) ResendVerificationEmail(ctx context.Context, email string, password string) error

Resend verification email (for users that already exist) Will return an error if user does not exist Idempotent within a certain period of time

func (*UserService) ResetPassword

func (u *UserService) ResetPassword(ctx context.Context, email string) error

Sends initial request to reset password for user with email Sends an email to the user with reset token if account with email exists

func (*UserService) ResetPwAuthCodeExchange

func (u *UserService) ResetPwAuthCodeExchange(ctx context.Context, token string, email string) (string, error)

func (*UserService) SetNewPassword

func (u *UserService) SetNewPassword(ctx context.Context, email string, authCode string, newPassword string) error

func (*UserService) VerifyEmail

func (u *UserService) VerifyEmail(ctx context.Context, userUUID string, verificationToken string) error

Jump to

Keyboard shortcuts

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