auth

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(us UserSystem, wx WeixinSupport, wb WeiboSupport,
	qqsp QqSupport, mobile MobileSupport, oauth OAuthSupport)

func MobilePreRegister

func MobilePreRegister(mobile string) (string, error)

func MobilePreSet

func MobilePreSet(mobile string, id appgo.Id) (string, error)

func MobilePwReset

func MobilePwReset(mobile string) (string, error)

func MobileVerifyPwReset

func MobileVerifyPwReset(mobile, code, password string) error

func MobileVerifyRegister

func MobileVerifyRegister(mobile, code string) (string, error)

func MobileVerifySet

func MobileVerifySet(mobile string, id appgo.Id, code string) error

Types

type LoginResult

type LoginResult struct {
	UserId   appgo.Id
	Token    Token
	UserInfo interface{}
	Banned   bool
	BanInfo  interface{}
}

func LoginByMobile

func LoginByMobile(mobile, password string, role appgo.Role) (*LoginResult, error)

func LoginByOAuth

func LoginByOAuth(code string, index int, role appgo.Role) (*LoginResult, error)

func LoginByQq

func LoginByQq(openId, token string, role appgo.Role) (*LoginResult, error)

func LoginByWeibo

func LoginByWeibo(openId, token, code string, role appgo.Role) (*LoginResult, error)

func LoginByWeixin

func LoginByWeixin(openId, token, code string, role appgo.Role) (*LoginResult, error)

func MobileRegisterUser

func MobileRegisterUser(info *MobileUserInfo, role appgo.Role) (*LoginResult, error)

type MobileSupport

type MobileSupport interface {
	HasMobileUser(mobile string) (bool, error)
	GetMobileUser(mobile, password string) (uid appgo.Id, err error)
	AddMobileUser(info *MobileUserInfo) (uid appgo.Id, err error)
	UpdatePwByMobile(mobile, password string) error
	SetMobileForUser(mobile string, userId appgo.Id) error
	appgo.MobileMsgSender
	appgo.KvStore
}

type MobileUserInfo

type MobileUserInfo struct {
	Mobile   string
	Token    string
	Nickname string
	Portrait string
	Password string
	Sex      appgo.Sex
}

type OAuthSupport

type OAuthSupport interface {
	GetOAuthUser(index int, id string) (uid appgo.Id, err error)
	GetOAuthUserInfo(index int, code string) (interface{}, string, error)
	AddOAuthUser(index int, id string, info interface{}) (uid appgo.Id, err error)
}

type QqSupport

type QqSupport interface {
	GetQqUser(openId string) (uid appgo.Id, err error)
	AddQqUser(info *qq.UserInfo) (uid appgo.Id, err error)
}

type Token

type Token string

func NewToken

func NewToken(userId appgo.Id, role appgo.Role) Token

func (Token) Validate

func (t Token) Validate() (appgo.Id, appgo.Role)

type UserSystem

type UserSystem interface {
	// extraInfo should be ban info if banned is true, userInfo otherwise
	CheckIn(id appgo.Id, role appgo.Role,
		newToken Token) (banned bool, extraInfo interface{}, err error)
}

type WeiboSupport

type WeiboSupport interface {
	GetWeiboUser(unionId string) (uid appgo.Id, err error)
	AddWeiboUser(info *weibo.UserInfo) (uid appgo.Id, err error)
}

type WeixinSupport

type WeixinSupport interface {
	GetWeixinUser(unionId string) (uid appgo.Id, err error)
	AddWeixinUser(info *weixin.UserInfo) (uid appgo.Id, err error)
}

Jump to

Keyboard shortcuts

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