models

package
v0.0.0-...-2696cb8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOTUInvalid = errors.New("invalid or expired OTU")

Functions

func CreatePreSignedURL

func CreatePreSignedURL(otu *OneTimeURL) (err error)

func CreateRole

func CreateRole(Role *Role) (err error)

Create a role

func GetOTU

func GetOTU(otu *OneTimeURL, id int) (err error)

func GetOTUs

func GetOTUs(otu *[]OneTimeURL) (err error)

func GetRole

func GetRole(Role *Role, id int) (err error)

Get role by id

func GetRoles

func GetRoles(Role *[]Role) (err error)

Get all roles

func GetUser

func GetUser(User *User, id int) (err error)

Get user by id

func GetUsers

func GetUsers(User *[]User) (err error)

Get all users

func UpdateRole

func UpdateRole(Role *Role) (err error)

Update role

func UpdateUser

func UpdateUser(User *User) (err error)

Update user

func VerifyOTU

func VerifyOTU(token string) error

Types

type OneTimeURL

type OneTimeURL struct {
	ID        uint `gorm:"primary_key"`
	Token     string
	Used      bool
	CreatedAt time.Time
}

type Role

type Role struct {
	gorm.Model
	ID          uint   `gorm:"primary_key"`
	Name        string `gorm:"size:50;not null;unique" json:"name"`
	Description string `gorm:"size:255;not null" json:"description"`
}

Role model

type User

type User struct {
	gorm.Model
	ID       uint   `gorm:"primary_key"`
	RoleID   uint   `gorm:"not null;DEFAULT:3" json:"role_id"`
	Email    string `gorm:"size:255;not null;unique" json:"email"`
	Password string `gorm:"size:255;not null" json:"-"`
	Role     Role   `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
}

func GetUserById

func GetUserById(id uint) (User, error)

Get user by id

func GetUserByUsername

func GetUserByUsername(username string) (User, error)

Get user by username

func (*User) BeforeSave

func (user *User) BeforeSave(*gorm.DB) error

Gen encrypted Pass

func (*User) Save

func (user *User) Save() (*User, error)

func (*User) ValidateUserPassword

func (user *User) ValidateUserPassword(password string) error

Validate user password

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳