- tiny refactor

This commit is contained in:
gazebo
2019-01-29 09:36:58 +08:00
parent e3f91906a1
commit 9ed9175938
3 changed files with 6 additions and 3 deletions

View File

@@ -28,6 +28,8 @@ var (
ErrUserNotExist = errors.New("用户不存在,请联系运营创建")
ErrLoginTypeNotSupported = errors.New("不支持指定的登录类型")
ErrUIDAndPassNotMatch = errors.New("用户与密码不匹配")
ErrAPINeedRealLogin = errors.New("此API要求真正登录")
ErrIllegalLoginType = errors.New("不支持的登录类型")
)
type LoginInfo struct {

View File

@@ -139,7 +139,7 @@ func BindMobile(token, mobileNum, code, nickname string) (err error) {
// 绑定手机加登录
func BindMobile2(openid, secret, mobileNum, verifyCode, nickname string) (loginInfo *auth.LoginInfo, err error) {
globals.SugarLogger.Debugf("BindMobileEx openid:%s, secret:%s, mobileNum:%s, verifyCode:%s, nickname:%s", openid, secret, mobileNum, verifyCode, nickname)
globals.SugarLogger.Debugf("BindMobile2 openid:%s, secret:%s, mobileNum:%s, verifyCode:%s, nickname:%s", openid, secret, mobileNum, verifyCode, nickname)
err = ErrExceptionalLogin
if value := api.Cacher.Get(openid); value != nil {

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
@@ -72,12 +73,12 @@ func GetUserInfo(ctx *jxcontext.Context, mobile string) (storeUserInfo *StoreUse
func GetSelfInfo(ctx *jxcontext.Context) (storeUserInfo *StoreUserInfo, err error) {
loginInfo := ctx.GetLoginInfo()
if loginInfo == nil {
return nil, fmt.Errorf("此API要求真正登录")
return nil, auth.ErrAPINeedRealLogin
}
fieldName := LoginTypeFieldMap[loginInfo.LoginType]
if fieldName == "" {
return nil, fmt.Errorf("不支持的登录类型")
return nil, auth.ErrIllegalLoginType
}
sql := fmt.Sprintf(`
SELECT t1.id, IF(t3.id IS NULL, t1.jxstoreid, t3.jxstoreid) jxstoreid, t1.openid, t1.tel, t1.nickname, t1.parentid, t3.tel parent_mobile,