nut

package
v0.0.0-...-00e0705 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2018 License: MIT Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RoleAdmin admin role
	RoleAdmin = "admin"
	// RoleRoot root role
	RoleRoot = "root"
	// UserTypeEmail email user
	UserTypeEmail = "email"

	// DefaultResourceType default resource type
	DefaultResourceType = "nil"
	// DefaultResourceID default resourc id
	DefaultResourceID = math.MaxInt64
)
View Source
const (

	// SendEmailJob send email
	SendEmailJob = "send.email"
)

Variables

This section is empty.

Functions

func CreateCertificate

func CreateCertificate(ca bool, subject pkix.Name, years int) ([]byte, []byte, error)

CreateCertificate create certs

func WritePemFile

func WritePemFile(file, _type string, buf []byte, mode os.FileMode) error

WritePemFile wirte to a pem format file

Types

type Attachment

type Attachment struct {
	ID           uint      `json:"id"`
	Title        string    `json:"title"`
	URL          string    `json:"url"`
	Length       int64     `json:"length"`
	MediaType    string    `json:"mediaType"`
	ResourceID   uint      `json:"resourceId"`
	ResourceType string    `json:"resourceType"`
	UpdatedAt    time.Time `json:"updatedAt"`
	CreatedAt    time.Time `json:"crateAt"`

	User   *User `json:"user"`
	UserID uint  `json:"userId"`
	// contains filtered or unexported fields
}

Attachment attachment

func (*Attachment) IsPicture

func (p *Attachment) IsPicture() bool

IsPicture is picture?

type Card

type Card struct {
	ID        uint      `json:"id"`
	Lang      string    `json:"lang"`
	Loc       string    `json:"loc"`
	Title     string    `json:"title"`
	Summary   string    `json:"summary"`
	Type      string    `json:"type"`
	Href      string    `json:"href"`
	Sort      int       `json:"sort" sql:",notnull"`
	Action    string    `json:"action"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Card card

type Dao

type Dao struct {
	Security *web.Security `inject:""`
	I18n     *i18n.I18n    `inject:""`
}

Dao dao

func (*Dao) AddEmailUser

func (p *Dao) AddEmailUser(db orm.DB, lang, ip, name, email, password string) (*User, error)

AddEmailUser add email user

func (*Dao) AddLog

func (p *Dao) AddLog(db orm.DB, user uint, ip, lang, format string, args ...interface{}) error

AddLog add log

func (*Dao) Allow

func (p *Dao) Allow(db orm.DB, user uint, role uint, years, months, days int) error

Allow allow permission

func (*Dao) Authority

func (p *Dao) Authority(db orm.DB, user uint, rty string, rid uint) ([]string, error)

Authority get roles

func (*Dao) Can

func (p *Dao) Can(db orm.DB, user uint, name string, rty string, rid uint) bool

Can can?

func (*Dao) Deny

func (p *Dao) Deny(db orm.DB, user uint, role uint) error

Deny deny permission

func (*Dao) GetRole

func (p *Dao) GetRole(db orm.DB, name string, rty string, rid uint) (*Role, error)

GetRole create role if not exist

func (*Dao) GetUserByEmail

func (p *Dao) GetUserByEmail(tx orm.DB, email string) (*User, error)

GetUserByEmail get user by email

func (*Dao) GetUserByUID

func (p *Dao) GetUserByUID(tx orm.DB, uid string) (*User, error)

GetUserByUID get user by uid

func (*Dao) Is

func (p *Dao) Is(db orm.DB, user uint, names ...string) bool

Is is role ?

func (*Dao) SignIn

func (p *Dao) SignIn(db orm.DB, lang, ip, email, password string) (*User, error)

SignIn set sign-in info

type FriendLink struct {
	ID        uint      `json:"id"`
	Title     string    `json:"title"`
	Home      string    `json:"home"`
	Sort      int       `json:"sort" sql:",notnull"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

FriendLink friend_links

type HTMLHandlerFunc

type HTMLHandlerFunc func(string, *mux.Context) error

HTMLHandlerFunc html handler func

type Layout

type Layout struct {
	I18n     *i18n.I18n         `inject:""`
	Settings *settings.Settings `inject:""`
	Jwt      *web.Jwt           `inject:""`
	DB       *pg.DB             `inject:""`
	Dao      *Dao               `inject:""`
}

Layout layout

func (*Layout) CurrentUser

func (p *Layout) CurrentUser(c *mux.Context) (*User, error)

CurrentUser parse user from request

func (*Layout) IsAdmin

func (p *Layout) IsAdmin(c *mux.Context) (*User, error)

IsAdmin is admin

type LeaveWord

type LeaveWord struct {
	ID        uint      `json:"id"`
	Body      string    `json:"body"`
	Type      string    `json:"type"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

LeaveWord leave-word

type Link struct {
	ID        uint      `json:"id"`
	Lang      string    `json:"lang"`
	Loc       string    `json:"loc"`
	X         int       `json:"x" sql:",notnull"`
	Y         int       `json:"y" sql:",notnull"`
	Href      string    `json:"href"`
	Label     string    `json:"label"`
	UpdatedAt time.Time `json:"updatedAt"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Link link

type Log

type Log struct {
	ID        uint      `json:"id"`
	Message   string    `json:"message"`
	IP        string    `json:"ip"`
	User      *User     `json:"user"`
	UserID    uint      `json:"userId"`
	CreatedAt time.Time `json:"createdAt"`
	// contains filtered or unexported fields
}

Log log

func (Log) String

func (p Log) String() string

type ObjectHandlerFunc

type ObjectHandlerFunc func(string, *mux.Context) (interface{}, error)

ObjectHandlerFunc object handle func

type Plugin

type Plugin struct {
	Redis    *redis.Pool        `inject:""`
	I18n     *i18n.I18n         `inject:""`
	Cache    cache.Cache        `inject:""`
	Jwt      *web.Jwt           `inject:""`
	Queue    queue.Queue        `inject:""`
	Settings *settings.Settings `inject:""`
	Security *web.Security      `inject:""`
	Storage  storage.Storage    `inject:""`
	Router   *mux.Router        `inject:""`
	DB       *pg.DB             `inject:""`
	Dao      *Dao               `inject:""`
	Layout   *Layout            `inject:""`
}

Plugin plugin

func (*Plugin) Init

func (p *Plugin) Init(g *inject.Graph) error

Init init beans

func (*Plugin) Mount

func (p *Plugin) Mount() error

Mount register

func (*Plugin) Shell

func (p *Plugin) Shell() []cli.Command

Shell console commands

type Policy

type Policy struct {
	ID        uint
	Nbf       time.Time
	Exp       time.Time
	UpdatedAt time.Time
	CreatedAt time.Time

	User   *User
	UserID uint
	Role   *Role
	RoleID uint
	// contains filtered or unexported fields
}

Policy policy

func (*Policy) Enable

func (p *Policy) Enable() bool

Enable is enable?

type RedirectHandlerFunc

type RedirectHandlerFunc func(string, *mux.Context) error

RedirectHandlerFunc redirect handle func

type Role

type Role struct {
	ID           uint
	Name         string
	ResourceID   uint
	ResourceType string
	UpdatedAt    time.Time
	CreatedAt    time.Time
	// contains filtered or unexported fields
}

Role role

func (Role) String

func (p Role) String() string

type User

type User struct {
	ID              uint       `json:"id"`
	Name            string     `json:"name"`
	Email           string     `json:"email"`
	UID             string     `json:"uid"`
	Password        []byte     `json:"-"`
	ProviderID      string     `json:"providerId"`
	ProviderType    string     `json:"providerType"`
	SignInCount     uint       `json:"signInCount"`
	LastSignInAt    *time.Time `json:"lastSignInAt"`
	LastSignInIP    string     `json:"lastSignInIp"`
	CurrentSignInAt *time.Time `json:"currentSignInAt"`
	CurrentSignInIP string     `json:"currentSignInIp"`
	ConfirmedAt     *time.Time `json:"confirmedAt"`
	LockedAt        *time.Time `json:"lockAt"`
	UpdatedAt       time.Time  `json:"updatedAt"`
	CreatedAt       time.Time  `json:"createdAt"`

	Logs []Log `json:"logs"`
	// contains filtered or unexported fields
}

User user

func (*User) IsConfirm

func (p *User) IsConfirm() bool

IsConfirm is confirm?

func (*User) IsLock

func (p *User) IsLock() bool

IsLock is lock?

func (p *User) SetGravatarLogo()

SetGravatarLogo set logo by gravatar

func (*User) SetUID

func (p *User) SetUID()

SetUID generate uid

func (User) String

func (p User) String() string

type Vote

type Vote struct {
	ID           uint
	Point        int
	ResourceID   uint
	ResourceType string
	UpdatedAt    time.Time
	CreatedAt    time.Time
	// contains filtered or unexported fields
}

Vote vote

Jump to

Keyboard shortcuts

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