作者 yangfu

登录修改

... ... @@ -18,6 +18,9 @@ service Core {
@handler miniUserApplyJoinCompany
post /mini/user/apply_join_company(MiniUserApplyJoinCompanyRequest) returns (MiniUserApplyJoinCompanyResponse)
@doc "用户登录"
@handler miniUserWXLogin
post /mini/user/wx-login (MiniUserLoginRequest) returns (MiniUserLoginResponse)
@doc "用户登录"
@handler miniUserLogin
post /mini/user/login (MiniUserLoginRequest) returns (MiniUserLoginResponse)
}
... ... @@ -75,6 +78,16 @@ service Core {
}
type(
MiniUserWXLoginRequest {
Code string `json:"code"` // 授权码
}
MiniUserLoginResponse {
SessionKey string `json:"sessionKey"`
OpenId string `json:"openId"`
}
)
type(
MiniUserLoginRequest {
LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
... ...
... ... @@ -7,7 +7,7 @@ Timeout: 30000
# CertFile: ./key/fjmaimaimai.com_bundle.crt
# KeyFile: ./key/fjmaimaimai.com.key
Log:
Mode: file
#Mode: file
Encoding: plain
Level: debug # info
MaxSize: 1 # 2MB
... ... @@ -32,3 +32,7 @@ ApiAuth:
Name: ApiAuth
Host: http://digital-platform-dev.fjmaimaimai.com
Timeout: 0s
Wechat:
AppID: wxae5b305849343ec8
AppSecret: f584adb68f7d784425b60e1ebb2ffd4b
\ No newline at end of file
... ...
... ... @@ -63,6 +63,7 @@ func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (res
Success: true,
}
if loginInfo.User == nil {
resp.Token = ""
resp.Success = false
}
return
... ... @@ -88,6 +89,9 @@ type WxClientLogin struct {
func (c WxClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.LoginInfo, error) {
code := r.Code
response := &domain.LoginInfo{
Phone: "",
}
miniprogram := wechat.NewWechat().GetMiniProgram(&miniConfig.Config{
AppID: c.l.svcCtx.Config.Wechat.AppID,
AppSecret: c.l.svcCtx.Config.Wechat.AppSecret,
... ... @@ -95,7 +99,7 @@ func (c WxClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.Lo
})
authResult, err := miniprogram.GetAuth().GetPhoneNumber(code)
if err != nil || authResult.ErrCode != 0 || authResult.PhoneInfo.PhoneNumber == "" {
return nil, xerr.NewCodeErrMsg(xerr.ErrWxMiniAuthFailError, nil, fmt.Sprintf("发起授权请求失败1 err : %v , code : %s , authResult : %+v", err, code, authResult))
return response, xerr.NewCodeErrMsg(xerr.ErrWxMiniAuthFailError, nil, fmt.Sprintf("发起授权请求失败1 err : %v , code : %s , authResult : %+v", err, code, authResult))
}
var (
users []*domain.User
... ... @@ -106,11 +110,9 @@ func (c WxClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.Lo
MustWithKV("phone", phone).
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
if err != nil {
return nil, err
}
response := &domain.LoginInfo{
Phone: phone,
return response, err
}
response.Phone = phone
if len(users) != 0 {
response.User = users[0]
}
... ...