user

package
v0.0.0-...-849f898 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LoginWxMiniApp login by wx app
	LoginWxMiniApp = "wx_miniapp"
	// LoginByWxH5 login by wx h5
	LoginByWxH5 = "wx_h5"
	// LoginByWxQr login by wx qr
	LoginByWxQr = "wx_qr"
	// LoginByWxApp login by wx app
	LoginByWxApp = "wx_app"
	// LoginByMobile login by wx app
	LoginByMobile = "mobile"
)

Variables

This section is empty.

Functions

func Init

func Init(dbOrm *gorm.DB) error

Init must be called before UserDaoInst

func UpdateUserInfoByWxMiniApp

func UpdateUserInfoByWxMiniApp(ctx context.Context, wxConfig *wechat.WxConfig, reqData *userInfoUpdateReqData) error

UpdateUserInfoByWxMiniApp 更新用户信息

func UserDaoInst

func UserDaoInst() *model.UserDao

UserDaoInst ...

Types

type LoginMobileParams

type LoginMobileParams struct {
	Phone    string `json:"phone"` // 手机号
	Code     string `json:"code"`  // 验证码
	CodeType string `json:"type"`  // 验证码序列号
}

LoginMobileParams args

type LoginQQParams

type LoginQQParams struct {
	AccessToken string `json:"access_token"`
}

LoginQQParams args

type LoginRequest

type LoginRequest struct {
	InviterId     string            `json:"inviter_uuid"`
	InviteScene   string            `json:"invite_scene"`
	InvitePayload json.RawMessage   `json:"invite_payload,omitempty"`
	Platform      string            `json:"platform"`
	LoginType     string            `json:"login_type"` // 登录方式
	WX            LoginWxParams     `json:"wx"`         // 微信登录
	QQ            LoginQQParams     `json:"qq"`         // QQ登录
	Mobile        LoginMobileParams `json:"mobile"`     // 手机登录
}

LoginRequest args

type LoginResponse

type LoginResponse struct {
	Uuid    string `json:"uuid"`
	NewUser int    `json:"new_user"`
	Token   string `json:"token"`
}

LoginResponse ...

func Login

func Login(ctx context.Context, req *LoginRequest) (resp *LoginResponse, err error)

Login login

func LoginByWxMiniApp

func LoginByWxMiniApp(ctx context.Context, appid, appname, appsecret, jsCode, inviter string) (*LoginResponse, error)

LoginByWxMiniApp authorizate and register wechat user

type LoginWxParams

type LoginWxParams struct {
	Code string `json:"code" yaml:"code"`
}

LoginWxParams args

type SessHelper

type SessHelper struct {
	// contains filtered or unexported fields
}

SessHelper with this object, we can handle the uuid and token conveniently

func SessHelperInst

func SessHelperInst() *SessHelper

SessHelperInst the global instance for SessHelper

func (*SessHelper) DeleteToken

func (s *SessHelper) DeleteToken(appid, uuid string) error

DeleteToken delete the current token of uuid

func (*SessHelper) GetToken

func (s *SessHelper) GetToken(appid, uuid string) (string, error)

GetToken get the token for uuid

func (*SessHelper) SetRedis

func (s *SessHelper) SetRedis(cli *redis.Client) error

SetRedis ...

func (*SessHelper) UpdateToken

func (s *SessHelper) UpdateToken(appid, uuid, token string, expireMS int) error

UpdateToken update the token for uuid

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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