model

package
v1.6.34 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package model contains all the models required for a functional database management system

Index

Constants

View Source
const (
	EmailNotVerified       int8 = -1
	EmailVerifyNotRequired int8 = 0
	EmailVerified          int8 = 1
)

Email verification statuses

View Source
const (
	EmailTypeVerifyEmailNewAcc  int = 1 // verify email of newly registered user
	EmailTypePassRecovery       int = 2 // password recovery code
	EmailTypeVerifyUpdatedEmail int = 3 // verify request of updating user email
)

Email type

View Source
const (
	EmailVerificationKeyPrefix string = "gorest-email-verification-"
	EmailUpdateKeyPrefix       string = "gorest-email-update-"
	PasswordRecoveryKeyPrefix  string = "gorest-pass-recover-"
)

Redis key prefixes

Variables

View Source
var InMemorySecret2FA = make(map[uint64]Secret2FA)

InMemorySecret2FA - keep secrets temporarily in memory to setup 2FA

Functions

This section is empty.

Types

type Auth

type Auth struct {
	AuthID      uint64         `gorm:"primaryKey" json:"authID,omitempty"`
	CreatedAt   time.Time      `json:"createdAt,omitempty"`
	UpdatedAt   time.Time      `json:"updatedAt,omitempty"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
	Email       string         `gorm:"index" json:"email"`
	EmailCipher string         `json:"-"`
	EmailNonce  string         `json:"-"`
	EmailHash   string         `gorm:"index" json:"-"`
	Password    string         `json:"password"`
	VerifyEmail int8           `json:"-"`
}

Auth model - `auths` table

func (Auth) MarshalJSON

func (v Auth) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Auth) UnmarshalJSON

func (v *Auth) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type AuthPayload added in v1.6.1

type AuthPayload struct {
	Email    string `json:"email,omitempty"`
	Password string `json:"password,omitempty"`

	VerificationCode string `json:"verificationCode,omitempty"`

	OTP string `json:"otp,omitempty"`

	SecretCode  string `json:"secretCode,omitempty"`
	RecoveryKey string `json:"recoveryKey,omitempty"`

	PassNew    string `json:"passNew,omitempty"`
	PassRepeat string `json:"passRepeat,omitempty"`
}

AuthPayload - struct to handle all auth data

type HTTPResponse added in v1.6.1

type HTTPResponse struct {
	Message interface{} `json:"message,omitempty"`
}

HTTPResponse - final response to the api consumers

type KeyValue added in v1.6.9

type KeyValue struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

KeyValue - general model to process key-value pair

type Secret2FA added in v1.6.1

type Secret2FA struct {
	PassSHA []byte `json:"-"`
	Secret  []byte `json:"-"`
	Image   string `json:"-"`
}

Secret2FA - save encoded secrets in RAM temporarily

type TempEmail added in v1.6.19

type TempEmail struct {
	ID          uint64    `gorm:"primaryKey" json:"-"`
	CreatedAt   time.Time `json:"createdAt,omitempty"`
	UpdatedAt   time.Time `json:"updatedAt,omitempty"`
	Email       string    `gorm:"index" json:"emailNew"`
	Password    string    `gorm:"-" json:"password,omitempty"`
	EmailCipher string    `json:"-"`
	EmailNonce  string    `json:"-"`
	EmailHash   string    `gorm:"index" json:"-"`
	IDAuth      uint64    `gorm:"index" json:"-"`
}

TempEmail - 'temp_emails' table to hold data temporarily during the process of replacing a user's email address with a new one

type TwoFA added in v1.6.1

type TwoFA struct {
	ID        uint64         `gorm:"primaryKey" json:"-"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	KeyMain   string         `json:"-"`
	KeyBackup string         `json:"-"`
	UUIDSHA   string         `json:"-"`
	UUIDEnc   string         `json:"-"`
	Status    string         `json:"-"`
	IDAuth    uint64         `gorm:"index" json:"-"`
}

TwoFA model - 'two_fas' table

type TwoFABackup added in v1.6.18

type TwoFABackup struct {
	ID        uint64    `gorm:"primaryKey" json:"-"`
	CreatedAt time.Time `json:"-"`
	Code      string    `gorm:"-" json:"code"`
	CodeHash  string    `json:"-"`
	IDAuth    uint64    `gorm:"index" json:"-"`
}

TwoFABackup model - 'two_fa_backups' table

Jump to

Keyboard shortcuts

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