models

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiString added in v0.0.2

type MultiString []string

func (*MultiString) Scan added in v0.0.2

func (s *MultiString) Scan(src interface{}) error

func (MultiString) Value added in v0.0.2

func (s MultiString) Value() (driver.Value, error)

type User

type User struct {
	gorm.Model
	Username      string                 `gorm:"not null;unique" form:"username" json:"username,omitempty"`
	Password      string                 `gorm:"not null" form:"password" json:"-"`
	Email         string                 `gorm:"not null" json:"email,omitempty"`
	Roles         MultiString            `gorm:"type:text" json:"roles,omitempty"`
	Authorization string                 `json:"authorization,omitempty"`
	AuthorizedAt  time.Time              `json:"authorized_at,omitempty"`
	Token         json.RawMessage        `gorm:"type:json" json:"token,omitempty"`
	Fields        map[string]interface{} `gorm:"-" json:"fields,omitempty"`
}

User structure made exportable to be used with Gorm ORM

func (*User) GetAuthorization

func (u *User) GetAuthorization() (string, error)

GetAuthorization returns the authorization method, e.g. Basic Authentication.

func (*User) GetAuthorizedAt

func (u *User) GetAuthorizedAt() (time.Time, error)

GetAuthorizedAt returns the exact time the client has been authorized for the "first" time.

func (*User) GetEmail

func (u *User) GetEmail() (string, error)

GetEmail returns the e-mail of (string,error) User.

func (*User) GetField

func (u *User) GetField(key string) (interface{}, error)

GetField optionally returns a dynamic field from the `Fields` field based on its key.

func (*User) GetID

func (u *User) GetID() (string, error)

GetID returns the ID of the User.

func (*User) GetPassword

func (u *User) GetPassword() (string, error)

GetPassword returns the raw password of the User.

func (*User) GetRoles

func (u *User) GetRoles() ([]string, error)

GetRoles returns the specific user's roles. Returns with `ErrNotSupported` if the Roles field is not initialized.

func (*User) GetToken

func (u *User) GetToken() ([]byte, error)

GetToken returns the token associated with this User. It may return empty if the User is not featured with a Token.

The implementation can change that behavior. Returns with `ErrNotSupported` if the Token field is empty.

func (*User) GetUsername

func (u *User) GetUsername() (string, error)

GetUsername returns the name of the User.

Jump to

Keyboard shortcuts

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