RegisterUser支持token

This commit is contained in:
gazebo
2020-01-06 16:36:52 +08:00
parent fda22fa2d4
commit 170cd63936
5 changed files with 58 additions and 22 deletions

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