userSystem

package
v0.0.0-...-fad388b Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OnCreatedCallback

type OnCreatedCallback func(id appgo.Id) error

type UserData

type UserData struct {
	Id       appgo.Id
	Username *string
	Email    *string
	Mobile   *string
	Role     appgo.Role
	Platform appgo.Platform
	Nickname *string
	Portrait *string
	Sex      appgo.Sex
}

type UserDataFromOAuthCode

type UserDataFromOAuthCode func(code string) (*UserData, string, error)

type UserModel

type UserModel struct {
	Id            appgo.Id
	Username      sql.NullString `gorm:"size:63;unique_index"`
	Email         sql.NullString `gorm:"size:63;unique_index"`
	Mobile        sql.NullString `gorm:"size:15;unique_index"`
	PasswordSalt  []byte         `gorm:"size:64"`
	PasswordHash  []byte         `gorm:"size:64"`
	WeiboId       sql.NullString `gorm:"size:63;unique_index"`
	WeixinUnionId sql.NullString `gorm:"size:63;unique_index"`
	QqOpenId      sql.NullString `gorm:"size:63;unique_index"`
	OAuth0Id      sql.NullString `gorm:"size:63;unique_index"`
	OAuth1Id      sql.NullString `gorm:"size:63;unique_index"`
	// Only store appToken because webTokens are short lived
	AppToken     sql.NullString `gorm:"size:127"`
	Role         appgo.Role
	Platform     appgo.Platform
	PushProvider sql.NullString `gorm:"size:16"`
	PushToken    sql.NullString `gorm:"size:127"`
	Nickname     sql.NullString `gorm:"size:63"`
	Portrait     sql.NullString `gorm:"size:255"`
	Sex          appgo.Sex
	BannedUntil  *time.Time
	CreatedAt    time.Time
	DeletedAt    *time.Time
}

func (*UserModel) TableName

func (_ *UserModel) TableName() string

type UserSystem

type UserSystem struct {
	Pushers       map[string]appgo.Pusher
	DefaultPusher appgo.Pusher
	OnCreated     OnCreatedCallback
	OAuths        []UserDataFromOAuthCode
	appgo.MobileMsgSender
	appgo.KvStore
	// contains filtered or unexported fields
}
var U *UserSystem

func Init

func Init(db *gorm.DB, settings UserSystemSettings) *UserSystem

func (*UserSystem) AddMobileUser

func (u *UserSystem) AddMobileUser(info *auth.MobileUserInfo) (appgo.Id, error)

func (*UserSystem) AddOAuthUser

func (u *UserSystem) AddOAuthUser(index int, id string, ui interface{}) (appgo.Id, error)

func (*UserSystem) AddQqUser

func (u *UserSystem) AddQqUser(info *qq.UserInfo) (appgo.Id, error)

func (*UserSystem) AddWeiboUser

func (u *UserSystem) AddWeiboUser(info *weibo.UserInfo) (appgo.Id, error)

func (*UserSystem) AddWeixinUser

func (u *UserSystem) AddWeixinUser(info *weixin.UserInfo) (appgo.Id, error)

func (*UserSystem) CheckIn

func (u *UserSystem) CheckIn(id appgo.Id, role appgo.Role,
	newToken auth.Token) (banned bool, extraInfo interface{}, err error)

func (*UserSystem) CreateUser

func (u *UserSystem) CreateUser(user *UserData) (*UserData, error)

func (*UserSystem) DeleteUser

func (u *UserSystem) DeleteUser(id appgo.Id) error

func (*UserSystem) GetMobileUser

func (u *UserSystem) GetMobileUser(mobile, password string) (appgo.Id, error)

func (*UserSystem) GetOAuthUser

func (u *UserSystem) GetOAuthUser(index int, id string) (appgo.Id, error)

func (*UserSystem) GetOAuthUserInfo

func (u *UserSystem) GetOAuthUserInfo(index int, code string) (interface{}, string, error)

func (*UserSystem) GetPushTokens

func (u *UserSystem) GetPushTokens(ids []appgo.Id) (map[string]map[appgo.Id]*appgo.PushInfo, error)

func (*UserSystem) GetQqUser

func (u *UserSystem) GetQqUser(openId string) (appgo.Id, error)

func (*UserSystem) GetUserModel

func (u *UserSystem) GetUserModel(id appgo.Id) (*UserModel, error)

func (*UserSystem) GetWeiboUser

func (u *UserSystem) GetWeiboUser(openId string) (appgo.Id, error)

func (*UserSystem) GetWeixinUser

func (u *UserSystem) GetWeixinUser(unionId string) (appgo.Id, error)

func (*UserSystem) HasMobileUser

func (u *UserSystem) HasMobileUser(mobile string) (bool, error)

func (*UserSystem) ListUsers

func (u *UserSystem) ListUsers(offset, limit int) ([]*UserData, error)

func (*UserSystem) PushTo

func (u *UserSystem) PushTo(users []appgo.Id, content *appgo.PushData)

func (*UserSystem) ReadUser

func (u *UserSystem) ReadUser(id appgo.Id) (*UserData, error)

func (*UserSystem) Search

func (u *UserSystem) Search(keyword string, limit int) ([]*UserData, error)

func (*UserSystem) SetMobileForUser

func (u *UserSystem) SetMobileForUser(mobile string, userId appgo.Id) error

func (*UserSystem) SetPushToken

func (u *UserSystem) SetPushToken(id appgo.Id, platform appgo.Platform,
	provider, token string) error

func (*UserSystem) UpdateAppToken

func (u *UserSystem) UpdateAppToken(id appgo.Id, role appgo.Role) (string, error)

func (*UserSystem) UpdatePushInfo

func (u *UserSystem) UpdatePushInfo(id appgo.Id, pushInfo *appgo.PushInfo) error

func (*UserSystem) UpdatePwByMobile

func (u *UserSystem) UpdatePwByMobile(mobile, password string) error

func (*UserSystem) UpdateUser

func (u *UserSystem) UpdateUser(id appgo.Id, user *UserData) (*UserData, error)

func (*UserSystem) UserCount

func (u *UserSystem) UserCount() (int, error)

func (*UserSystem) Validate

func (u *UserSystem) Validate(token auth.Token) bool

type UserSystemSettings

type UserSystemSettings struct {
	TableName       string
	Pushers         []appgo.Pusher
	MobileMsgSender appgo.MobileMsgSender
	KvStore         appgo.KvStore
	OnCreated       OnCreatedCallback
	OAuths          []UserDataFromOAuthCode
}

Jump to

Keyboard shortcuts

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