Documentation
¶
Index ¶
- func GenerateSlug(s string) string
- func Now() *time.Time
- func TimeSetSQL(field string) string
- func TimeZeroSQL(field string) string
- func Unscoped(db *gorm.DB) *gorm.DB
- func UsersWithRole(role string) func(db *gorm.DB) *gorm.DB
- type Company
- type Credential
- type SourceType
- type User
- func (u *User) Find(preloads ...string) error
- func (u *User) ForgotMergeVars() map[string]string
- func (u *User) FullName() string
- func (u *User) HasRole(r string) bool
- func (u *User) IsAdmin() bool
- func (u *User) JwtToken() (string, error)
- func (u *User) Login() (*User, error)
- func (u *User) MergeVars() map[string]string
- func (u *User) RegisterWithPassword() error
- func (u *User) SetResetPasswordToken() error
- func (u *User) UpdatePassword() error
- func (u *User) UpdatePasswordByResetToken() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Company ¶
type Company struct {
ID int `jsonapi:"primary,company" gorm:"primary_key"`
Name string `jsonapi:"attr,name"`
Slug string `jsonapi:"attr,slug"`
Description string `jsonapi:"attr,description"`
Users []*User `jsonapi:"relation,users,omitempty" gorm:"save_associations:false"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
Company company data structure
type Credential ¶
type Credential struct {
ID int `jsonapi:"primary,credential"`
User User `jsonapi:"relation,user"`
UserID int
Source SourceType `sql:"not null;type:ENUM('password', 'facebook', 'google', 'confirm_token')"`
Value string
CreatedAt time.Time
UpdatedAt time.Time
}
Credential credential data structure
type SourceType ¶
type SourceType string
SourceType ...
const ( // Password ... Password SourceType = "password" // ConfirmToken ... ConfirmToken SourceType = "confirm_token" )
type User ¶
type User struct {
ID int `jsonapi:"primary,user" gorm:"primary_key"`
FirstName string `jsonapi:"attr,first_name" json:"first_name"`
LastName string `jsonapi:"attr,last_name" json:"last_name"`
Email string `jsonapi:"attr,email" valid:"email"`
Password string `jsonapi:"attr,password,omitempty" gorm:"-" sql:"-" valid:"length(6|100)~Password must be at least 6 characters"`
LastSigninAt time.Time `jsonapi:"attr,last_signin_at,iso8601"`
CreatedAt time.Time `jsonapi:"attr,created_at,iso8601"`
UpdatedAt time.Time `jsonapi:"attr,updated_at,iso8601"`
ResetToken string
Source string `jsonapi:"attr,source,omitempty" gorm:"-" sql:"-"`
Token string `jsonapi:"attr,token,omitempty" gorm:"-" sql:"-"`
URL string `gorm:"-" sql:"-" jsonapi:"attr,url,omitempty"`
Roles pq.StringArray `jsonapi:"attr,roles"`
RolesPayload []string `jsonapi:"attr,roles_payload" gorm:"-" sql:"-"`
CompanyID int `jsonapi:"attr,company_id,omitempty" json:"company_id"`
Company *Company `jsonapi:"relation,company,omitempty" gorm:"save_associations:false"`
}
User type
func (*User) ForgotMergeVars ¶
ForgotMergeVars ...
func (*User) RegisterWithPassword ¶
RegisterWithPassword ...
func (*User) SetResetPasswordToken ¶
SetResetPasswordToken ...
func (*User) UpdatePasswordByResetToken ¶
UpdatePasswordByResetToken ...
Click to show internal directories.
Click to hide internal directories.