data

package
v0.0.0-...-f805a98 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(i interface{}, r io.Reader) error

FromJSON deserializes the object from JSON string given in the io.Reader to the given interface

func ToJSON

func ToJSON(i interface{}, w io.Writer) error

ToJSON serializes the given interface into a string based JSON format

Types

type AuthDB

type AuthDB interface {
	Create(ctx context.Context, user *models.User) error
	GetUserByEmail(ctx context.Context, email string) (*models.User, error)
	GetUserByID(ctx context.Context, userID string) (*models.User, error)
	UpdateUsername(ctx context.Context, user *models.User) error
	UpdateUserVerificationStatus(ctx context.Context, email string, status bool) error
	StoreVerificationData(ctx context.Context, verificationData *models.VerificationData) error
	GetVerificationData(ctx context.Context, email string, verificationDataType models.VerificationDataType) (*models.VerificationData, error)
	DeleteVerificationData(ctx context.Context, email string, verificationDataType models.VerificationDataType) error
	UpdatePassword(ctx context.Context, userID string, password string, tokenHash string) error
}

type DB

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

func (*DB) Close

func (d *DB) Close() error

func (*DB) Create

func (d *DB) Create(ctx context.Context, user *models.User) error

Create inserts the given user into the database

func (*DB) DeleteVerificationData

func (d *DB) DeleteVerificationData(ctx context.Context, email string, verificationDataType models.VerificationDataType) error

DeleteMailVerificationData deletes a used verification data

func (*DB) GetUserByEmail

func (d *DB) GetUserByEmail(ctx context.Context, email string) (*models.User, error)

GetUserByEmail retrieves the user object having the given email, else returns error

func (*DB) GetUserByID

func (d *DB) GetUserByID(ctx context.Context, userID string) (*models.User, error)

GetUserByID retrieves the user object having the given ID, else returns error

func (*DB) GetVerificationData

func (d *DB) GetVerificationData(ctx context.Context, email string, verificationDataType models.VerificationDataType) (*models.VerificationData, error)

GetMailVerificationCode retrieves the stored verification code.

func (*DB) Open

func (d *DB) Open(config *utils.Configurations) error

func (*DB) SetDBLogger

func (d *DB) SetDBLogger(logger *zap.Logger)

func (*DB) StoreVerificationData

func (d *DB) StoreVerificationData(ctx context.Context, verificationData *models.VerificationData) error

StoreMailVerificationData adds a mail verification data to db

func (*DB) UpdatePassword

func (d *DB) UpdatePassword(ctx context.Context, userID string, password string, tokenHash string) error

UpdatePassword updates the user password

func (*DB) UpdateUserVerificationStatus

func (d *DB) UpdateUserVerificationStatus(ctx context.Context, email string, status bool) error

UpdateUserVerificationStatus updates user verification status to true

func (*DB) UpdateUsername

func (d *DB) UpdateUsername(ctx context.Context, user *models.User) error

UpdateUsername updates the username of the given user

type GoDB

type GoDB interface {
	AuthDB
	Open(config *utils.Configurations) error
	Close() error
	SetDBLogger(logger *zap.Logger)
}

type Validation

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

Validation is the type for validator

func NewValidation

func NewValidation() *Validation

NewValidation returns a Validator instance

func (*Validation) Validate

func (v *Validation) Validate(i interface{}) ValidationErrors

Validate method validates the given struct based on the validate tags and returns validation error if any

type ValidationError

type ValidationError struct {
	validator.FieldError
}

ValidationError wraps the validator FieldError so we do not expose this to outside code

func (ValidationError) Error

func (v ValidationError) Error() string

Error provides the string format of the validation error

type ValidationErrors

type ValidationErrors []ValidationError

ValidationErrors is a wrapper for list of ValidationError

func (ValidationErrors) Errors

func (v ValidationErrors) Errors() []string

Errors convert the ValidationErrors slice into string slice

Jump to

Keyboard shortcuts

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