models

package
v0.0.0-...-dbe4500 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLinksByUser

func GetLinksByUser(id string) (*[]Link, error)

GetLinksByUser eturns each link owned by given user id

func GetVisits

func GetVisits(link_id, start_time string) *[]VisitsPerDay

func HashPassword

func HashPassword(password []byte) (string, error)

HashPassword returns a hashed version of given password

func InitModels

func InitModels()

InitModels migrates modesls and initiates database connection

func ValidAPIKey

func ValidAPIKey(keyString string) (string, error)

Types

type APIKey

type APIKey struct {
	ID        string `gorm:"primaryKey;type:string;default:uuid_generate_v4()" json:"id,omitempty"`
	UserID    string
	CreatedAt int64 `gorm:"autoCreateTime" json:"created_at,omitempty"`
}

func GenerateAPIKey

func GenerateAPIKey(userID string) (APIKey, error)

type EmailVerification

type EmailVerification struct {
	Email string
	jwt.StandardClaims
}

EmailVerification jwt claims to be used to verify an email

type GDPRData

type GDPRData struct {
	UserData     User
	UserAuthData UserAuth
	Links        []Link
}

GDPRData structures GDPR Data

type GenericResponse

type GenericResponse struct {
	Data string `json:"data,omitempty"`
}

GenericResponse contains a generic string

type JWTClaims

type JWTClaims struct {
	UserID string
	jwt.StandardClaims
}

JWTClaims claims of the jwt

type Link struct {
	ID         string `gorm:"primaryKey;type:string;default:uuid_generate_v4()" json:"id,omitempty"`
	OwnerID    string `json:"owner_id"`
	Slug       string `gorm:"unique" json:"slug,omitempty"`
	URL        string `json:"url,omitempty"`
	UnlockTime int64  `json:"unlock_time"`
	Password   string `json:"password"`
	Visits     int    `json:"visits"`
	CreatedAt  int64  `gorm:"autoCreateTime" json:"created_at,omitempty"`
	UpdatedAt  int64  `gorm:"autoUpdateTime" json:"updated_at,omitempty"`
	Lease      int64  `json:"lease,omitempty"`
}

Link structure containing slug/URL pairs

func (*Link) Create

func (link *Link) Create() error

Create a db entry

func (*Link) Delete

func (link *Link) Delete() error

Delete a db entry2

func (*Link) Get

func (link *Link) Get() error

Get .

func (*Link) GetBySlug

func (link *Link) GetBySlug() error

Get link by slug

func (*Link) Put

func (link *Link) Put(uid string, field string, value interface{}) error

Put updates a link object

func (*Link) Read

func (link *Link) Read() error

Read a db entry by ID

func (*Link) Search

func (link *Link) Search() error

Search for db entry by slug

func (*Link) Update

func (link *Link) Update() error

Update a db entry by ID

type PasswordResetToken

type PasswordResetToken struct {
	User
	jwt.StandardClaims
}

PasswordResetToken contains whole user field and standard claims

type User

type User struct {
	UID       string `gorm:"primaryKey" json:"uid,omitempty"`
	Username  string `json:"display_name,omitempty"`
	Email     string `gorm:"unique" json:"email,omitempty"`
	CreatedAt int64  `gorm:"autoCreateTime" json:"created_at,omitempty"`
	UpdatedAt int64  `gorm:"autoUpdateTime" json:"updated_at,omitempty"`
}

User structure containing non-authenticative information

func (*User) Create

func (user *User) Create() error

Create user object

func (*User) Delete

func (user *User) Delete() error

Delete deletes a user's db entry

func (*User) Get

func (user *User) Get() error

Get user object

func (*User) Put

func (user *User) Put(field string, value interface{})

Put updates a user object

type UserAuth

type UserAuth struct {
	UID      string `gorm:"primaryKey;type:string;default:uuid_generate_v4()" json:"uid,omitempty"`
	Username string `gorm:"unique" json:"username,omitempty"`
	Email    string `gorm:"unique" json:"email,omitempty"`
	Hash     string `json:"hash,omitempty"`
	Enabled  bool   `json:"enabled"`
	Admin    bool   `json:"admin"`
}

UserAuth contains credentials stored serverside

func (*UserAuth) ChangePassword

func (user *UserAuth) ChangePassword(password string) error

func (*UserAuth) Create

func (user *UserAuth) Create(password string) error

Create user object

func (*UserAuth) Get

func (user *UserAuth) Get() error

Get userAuth data

func (*UserAuth) GetByEmail

func (user *UserAuth) GetByEmail() error

func (*UserAuth) Verify

func (user *UserAuth) Verify() error

Verify sets 'enabled' field to true

func (*UserAuth) VerifyPassword

func (user *UserAuth) VerifyPassword(password string) error

VerifyPassword compares provided plaintext password against stored hash

type Visit

type Visit struct {
	CreatedAt time.Time `json:"created_at"`
	LinkID    string    `json:"link_id"`
}

Visit structure containing time of visitation

func (*Visit) Create

func (visit *Visit) Create() error

Create a db entry

func (*Visit) Delete

func (visit *Visit) Delete() error

Delete a db entry2

func (*Visit) Update

func (visit *Visit) Update() error

Update a db entry by ID

type VisitsPerDay

type VisitsPerDay struct {
	Count int    `json:"count"`
	Date  string `json:"date"`
}

Jump to

Keyboard shortcuts

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