Documentation
¶
Index ¶
- type JSON
- type MultiString
- type User
- func (u *User) BeforeCreate(tx *gorm.DB) (err error)
- func (u *User) GetAuthorization() (string, error)
- func (u *User) GetAuthorizedAt() (time.Time, error)
- func (u *User) GetEmail() (string, error)
- func (u *User) GetField(key string) (interface{}, error)
- func (u *User) GetID() (string, error)
- func (u *User) GetPassword() (string, error)
- func (u *User) GetRoles() ([]string, error)
- func (u *User) GetToken() ([]byte, error)
- func (u *User) GetUsername() (string, error)
- func (u *User) IsValid() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSON ¶
type JSON json.RawMessage
JSON allows us to overload the json.Rawmessage type
type MultiString ¶
type MultiString []string
MultiString type is needed for gorm encapsulation
func (*MultiString) Scan ¶
func (s *MultiString) Scan(src interface{}) error
Scan is needed for gorm encapsulation
type User ¶
type User struct { ID uuid.UUID `gorm:"type:uuid;primarykey"` Username string `gorm:"not null;unique" form:"username" json:"username,omitempty"` Email string `gorm:"not null;unique" 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 `gorm:"type:text" json:"token,omitempty"` Fields map[string]interface{} `gorm:"-" json:"fields,omitempty"` Password string `gorm:"not null" form:"password" json:"-"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `gorm:"index"` }
User structure made exportable to be used with Gorm ORM
func (*User) BeforeCreate ¶ added in v0.1.22
BeforeCreate allow gorm to create the UUID field
func (*User) GetAuthorization ¶
GetAuthorization returns the authorization method, e.g. Basic Authentication.
func (*User) GetAuthorizedAt ¶
GetAuthorizedAt returns the exact time the client has been authorized for the "first" time.
func (*User) GetField ¶
GetField optionally returns a dynamic field from the `Fields` field based on its key.
func (*User) GetPassword ¶
GetPassword returns the raw password of the User.
func (*User) GetRoles ¶
GetRoles returns the specific user's roles. Returns with `ErrNotSupported` if the Roles field is not initialized.
func (*User) GetToken ¶
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 ¶
GetUsername returns the name of the User.