Documentation ¶
Index ¶
- Constants
- func ActiviateUser(user_id uint) (int64, error)
- func DeactivateUser(user_id uint) (int64, error)
- func GetDB() *gorm.DB
- func GetUserIDByAccessToken(token string) (uint, error)
- func GetUserIDByActivationToken(token string) (uint, error)
- func InitServerDB(dialector string, connection_str string, verbose bool) (*gorm.DB, error)
- type AuthUser
- type ProxyLog
- type UserToken
- type WhiteList
- type WhiteListUser
Constants ¶
View Source
const MaxExtendTimes = 31
View Source
const MaxTokenLifeSpan = 24 // in hours
Variables ¶
This section is empty.
Functions ¶
func ActiviateUser ¶
func DeactivateUser ¶
func GetUserIDByAccessToken ¶
Types ¶
type AuthUser ¶
type AuthUser struct { gorm.Model Username string `gorm:"type:varchar(64); not null;" json:"username"` Hostname string `gorm:"type:varchar(64); not null;" json:"hostname"` Email string `gorm:"type:varchar(128); not null;uniqueIndex:uniq_user" json:"email"` DeviceInfo string `gorm:"type:varchar(255); not null;" json:"device_info"` Password string `gorm:"type:varchar(255); not null;" json:"password"` IsActived uint `gorm:"not null; default:0;" json:"is_actived"` IsVerified uint `gorm:"not null; default:0;" json:"is_verified"` RegisterAt time.Time `gorm:"autoCreateTime" json:"register_at"` ExpiredAt time.Time `gorm:"index" json:"expired_at"` ActivateAt time.Time `json:"activate_at"` DeactivateAt time.Time `json:"deactivate_at"` }
func GetValidUser ¶
func (*AuthUser) VerifyUser ¶
type ProxyLog ¶
type ProxyLog struct { ID uint `gorm:"primary_key"` UserID uint `gorm:"not null"` // user id RemoteAddr string `gorm:"type:varchar(255)"` // remote ip address RequestTime time.Time `gorm:"not null"` // 请求时间 RequestMethod string `gorm:"not null"` // 请求方法 RequestURL string `gorm:"not null"` // 请求URL RequestHeaders string `gorm:"type:text"` // 请求头 RequestBody string `gorm:"type:longtext"` // 请求体 ResponseStatusCode int `gorm:"not null"` // 响应状态码 ResponseHeaders string `gorm:"type:text"` // 响应头 ResponseBody string `gorm:"type:longtext"` // 响应体 CreatedAt time.Time `gorm:"autoCreateTime"` // 创建时间 }
func (*ProxyLog) RecordRequest ¶
type UserToken ¶
type UserToken struct { gorm.Model TokenType string `gorm:"type:varchar(64); not null;" json:"token_type"` Token string `gorm:"type:char(36); not null;" json:"token"` ExpiredAt time.Time `gorm:"index" json:"expired_at"` UserID uint `json:"user_id"` ConsumeCounter uint `gorm:"not null; default:0;" json:"consume_counter"` }
func NewAccessToken ¶
func NewActiviationToken ¶
func RefreshAccessToken ¶
type WhiteList ¶
type WhiteList struct { // AvailableUserMap map[string]time.Time AvailableUserMap map[string]WhiteListUser Mutex *sync.RWMutex }
///////////////////////////////////////////////////////////////////////////
func (*WhiteList) GetUserInfoByToken ¶
func (w *WhiteList) GetUserInfoByToken(access_token string) *WhiteListUser
func (*WhiteList) IsAccessTokenValid ¶
func (*WhiteList) LoadWhiteList ¶
Click to show internal directories.
Click to hide internal directories.