models

package
v0.0.0-...-99024dd Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(userId, password string) map[string]interface{}

func DeleteKey

func DeleteKey(keyId string) map[string]interface{}

func DeleteUser

func DeleteUser(userId string) map[string]interface{}

func FetchAllKeyAccessLog

func FetchAllKeyAccessLog() map[string]interface{}

func FetchAllKeys

func FetchAllKeys() map[string]interface{}

func FetchAllUsers

func FetchAllUsers() map[string]interface{}

func GetDB

func GetDB() *gorm.DB

func GetKey

func GetKey(keyId string) map[string]interface{}

func GetUser

func GetUser(userId string) map[string]interface{}

func Login

func Login(email, password string) map[string]interface{}

func SeedFirstUser

func SeedFirstUser()

func UpdateUser

func UpdateUser(userId, name, email string) map[string]interface{}

Types

type Key

type Key struct {
	ID        uint       `gorm:"primary_key"`
	Domain    string     `gorm:"not null;unique_index" json:"domain"`
	Key       string     `gorm:"not null" json:"key"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	ExpiredAt *time.Time `json:"expired_at"`
	UpdateKey bool       `gorm:"-" json:"update_key"`
}

a struct to represent key

func (*Key) Create

func (key *Key) Create() map[string]interface{}

func (*Key) FindByDomain

func (key *Key) FindByDomain(domain string) bool

func (*Key) Validate

func (key *Key) Validate() (map[string]interface{}, bool)

Validate incoming user details...

type KeyAccessLog

type KeyAccessLog struct {
	Domain      string    `gorm:"not null;index" json:"domain"`
	Key         string    `gorm:"not null" json:"key"`
	Referrer    string    `json:"referrer"`
	UserAgent   string    `json:"referrer"`
	RequestedAt time.Time `gorm:"not null" json:"requested_at"`
	Status      bool      `gorm:"not null" json:"update_key"`
	Message     string    `json:"message"`
}

a struct to represent key access log

func (*KeyAccessLog) Create

func (keyAccessLog *KeyAccessLog) Create() bool

type Token

type Token struct {
	UserId uint
	jwt.StandardClaims
}

JWT claims struct

type User

type User struct {
	gorm.Model
	Name     string `gorm:"type:varchar(50);not null" json:"name"`
	Email    string `gorm:"type:varchar(100);not null;unique_index" json:"email"`
	Password string `gorm:"not null"`
	Token    string `gorm:"-" json:"token"`
}

a struct to represent users

func (*User) Create

func (user *User) Create() map[string]interface{}

func (*User) Validate

func (user *User) Validate() (map[string]interface{}, bool)

Validate incoming user details...

Jump to

Keyboard shortcuts

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