Merge remote-tracking branch 'origin/mark' into yonghui

This commit is contained in:
苏尹岚
2020-01-06 16:37:52 +08:00
5 changed files with 58 additions and 22 deletions

View File

@@ -13,7 +13,6 @@ import (
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego"
)
@@ -67,13 +66,13 @@ func (c *Auth2Controller) CreateCaptcha() {
// @router /SendVerifyCode [post]
func (c *Auth2Controller) SendVerifyCode() {
c.callSendVerifyCode(func(params *tAuth2SendVerifyCodeParams) (retVal interface{}, errCode string, err error) {
code, authInfo, err := auth2.SendVerifyCode(params.AuthToken, params.CaptchaID, params.CaptchaValue, params.AuthID)
if err == nil && authInfo != nil {
user, err2 := dao.GetUserByID(dao.GetDB(), "user_id", authInfo.GetID())
if err2 == nil && user.Type&(model.UserTypeBoss|model.UserTypeOperator) != 0 {
retVal = code
}
}
_, _, err = auth2.SendVerifyCode(params.AuthToken, params.CaptchaID, params.CaptchaValue, params.AuthID)
// if err == nil && authInfo != nil {
// user, err2 := dao.GetUserByID(dao.GetDB(), "user_id", authInfo.GetID())
// if err2 == nil && user.Type&(model.UserTypeBoss|model.UserTypeOperator) != 0 {
// retVal = code
// }
// }
return retVal, "", err
})
}

View File

@@ -20,6 +20,7 @@ type User2Controller struct {
// @Title 用户注册
// @Description 用户注册
// @Param token header string false "管理员token"
// @Param payload formData string true "json数据User对象(手机号必填)"
// @Param mobileVerifyCode formData string false "手机验证码通过auth2.SendVerifyCode获得mobileVerifyCode与authToken不能同时为空"
// @Param authToken formData string false "之前通过login得到的认证TOKENmobileVerifyCode与authToken不能同时为空"
@@ -29,16 +30,19 @@ type User2Controller struct {
func (c *User2Controller) RegisterUser() {
c.callRegisterUser(func(params *tUser2RegisterUserParams) (retVal interface{}, errCode string, err error) {
var (
user model.User
inAuthInfo *auth2.AuthInfo
user model.User
inAuthInfo, manTokenInfo *auth2.AuthInfo
)
if params.AuthToken != "" {
inAuthInfo, err = auth2.GetTokenInfo(params.AuthToken)
}
if params.Token != "" {
manTokenInfo, err = auth2.GetTokenInfo(params.Token)
}
if err == nil {
if err = jxutils.Strings2Objs(params.Payload, &user); err == nil {
user.Type = 0
retVal, err = cms.RegisterUserWithMobile(params.Ctx, &user, params.MobileVerifyCode, inAuthInfo)
retVal, err = cms.RegisterUserWithMobile(params.Ctx, &user, params.MobileVerifyCode, inAuthInfo, manTokenInfo)
}
}
return retVal, errCode, err