models

package
v0.0.0-...-80a4a0d Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	Name   string
	Model  interface{}
	Seeder *database.SeederDefinition
}

func RegisteredModels

func RegisteredModels() []Model

type PersonalAccessToken

type PersonalAccessToken struct {
	gorm.Model
	UserID    uint      `gorm:"not null"`
	User      User      `gorm:"foreignKey:UserID;not null"`
	Name      string    `gorm:"not null" json:"name"`
	Token     string    `gorm:"not null" json:"token"`
	ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
}

func (PersonalAccessToken) CreateTokenForUser

func (_ PersonalAccessToken) CreateTokenForUser(user User, name string, permanent bool) (PersonalAccessTokenResponse, error)

func (PersonalAccessToken) Find

func (PersonalAccessToken) Logout

func (pat PersonalAccessToken) Logout() error

func (PersonalAccessToken) RevokeToken

func (_ PersonalAccessToken) RevokeToken(token string) error

type PersonalAccessTokenResponse

type PersonalAccessTokenResponse struct {
	ID        uint      `json:"id"`
	UserID    uint      `json:"user_id"`
	Name      string    `json:"name"`
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

type User

type User struct {
	gorm.Model
	PersonalAccessToken []PersonalAccessToken `gorm:"foreignKey:UserID"`
	Name                string                `gorm:"not null"`
	Email               string                `gorm:"unique"`
	Password            string                `json:"-"`
}

func (User) FromAccessToken

func (_ User) FromAccessToken(token string) (*User, error)

func (User) LoggedInAccessToken

func (_ User) LoggedInAccessToken(c *fiber.Ctx) string

func (User) LoggedInUser

func (_ User) LoggedInUser(c *fiber.Ctx) *User

func (User) Login

func (_ User) Login(email string, password string) (*User, error)

func (User) Register

func (u User) Register() (*PersonalAccessTokenResponse, error)

Jump to

Keyboard shortcuts

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