Documentation ¶
Index ¶
- Constants
- type Attachment
- type Dao
- func (p *Dao) AddEmailUser(name, email, password string) (*User, error)
- func (p *Dao) Allow(role, user uint, years, months, days int) error
- func (p *Dao) Authority(user uint, rty string, rid uint) []string
- func (p *Dao) Can(user uint, name string, rty string, rid uint) bool
- func (p *Dao) Deny(role uint, user uint) error
- func (p *Dao) GetByEmail(email string) (*User, error)
- func (p *Dao) GetUserByUID(uid string) (*User, error)
- func (p *Dao) Is(user uint, names ...string) bool
- func (p *Dao) Log(user uint, ip, message string)
- func (p *Dao) Resources(user uint, role, rty string) ([]uint, error)
- func (p *Dao) Role(name string, rty string, rid uint) (*Role, error)
- func (p *Dao) SignIn(lang, email, password, ip string) (*User, error)
- func (p *Dao) Users(role, rty string, rid uint) ([]uint, error)
- type Jwt
- type Log
- type Plugin
- type Policy
- type Role
- type User
- type Vote
Constants ¶
View Source
const ( // TOKEN token session key TOKEN = "token" // UID uid key UID = "uid" // CurrentUser current-user key CurrentUser = "currentUser" // IsAdmin is-admin key IsAdmin = "isAdmin" )
View Source
const ( // RoleAdmin admin role RoleAdmin = "admin" // RoleRoot root role RoleRoot = "root" // UserTypeEmail email user UserTypeEmail = "email" // DefaultResourceType default resource type DefaultResourceType = "-" // DefaultResourceID default resourc id DefaultResourceID = 0 )
View Source
const (
// SendEmailJob send email
SendEmailJob = "send-email"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct { web.Model Title string `json:"title"` URL string `json:"url"` Length int64 `json:"length"` MediaType string `json:"mediaType"` ResourceID uint `json:"resourceId"` ResourceType string `json:"resourceType"` UserID uint `json:"userId"` User User `json:"-"` }
Attachment attachment
type Dao ¶
type Dao struct { Db *gorm.DB `inject:""` Hmac *security.Hmac `inject:""` I18n *i18n.I18n `inject:""` }
Dao auth dao
func (*Dao) AddEmailUser ¶
AddEmailUser add email user
func (*Dao) GetByEmail ¶
GetByEmail get user by email
func (*Dao) GetUserByUID ¶
GetUserByUID get user by uid
type Jwt ¶
type Jwt struct { Key []byte `inject:"jwt.key"` Method crypto.SigningMethod `inject:"jwt.method"` Dao *Dao `inject:""` I18n *i18n.I18n `inject:""` }
Jwt jwt helper
func (*Jwt) CurrentUserMiddleware ¶
CurrentUserMiddleware current-user middleware
func (*Jwt) MustAdminMiddleware ¶
MustAdminMiddleware must has admin role
func (*Jwt) MustSignInMiddleware ¶
MustSignInMiddleware must sign-in
type Log ¶
type Log struct { web.Timestamp Message string `json:"message"` Type string `json:"type"` IP string `json:"ip"` UserID uint `json:"userId"` User User `json:"-"` }
Log log
type Plugin ¶
type Plugin struct { Dao *Dao `inject:""` Jwt *Jwt `inject:""` Db *gorm.DB `inject:""` I18n *i18n.I18n `inject:""` Cache *cache.Cache `inject:""` Uploader uploader.Store `inject:""` Hmac *security.Hmac `inject:""` Server *job.Server `inject:""` Settings *settings.Settings `inject:""` }
Plugin plugin
type Policy ¶
type Policy struct { web.Model StartUp time.Time ShutDown time.Time UserID uint User User RoleID uint Role Role }
Policy policy
type User ¶
type User struct { web.Model Name string `json:"name"` Email string `json:"email"` UID string `json:"uid" gorm:"column:uid"` Password []byte `json:"-"` ProviderID string `json:"-"` ProviderType string `json:"providerType"` Home string `json:"home"` Logo string `json:"logo"` 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:"lockedAt"` Logs []Log `json:"-"` }
User user
func (*User) SetGravatarLogo ¶
func (p *User) SetGravatarLogo()
SetGravatarLogo set logo by gravatar
Click to show internal directories.
Click to hide internal directories.