小妖用户绑定微信
This commit is contained in:
@ -141,11 +141,16 @@ func (s *sUser) Login(ctx context.Context, in *model.UserLoginIn) (out *model.Us
|
|||||||
return nil, ecode.Fail.Sub("参数错误:用户不存在")
|
return nil, ecode.Fail.Sub("参数错误:用户不存在")
|
||||||
}
|
}
|
||||||
|
|
||||||
// User exists, bind in.OpenId and update last login store ID
|
// User exists, check WxOpenId
|
||||||
if err := dao.Users.Ctx(ctx).Where(do.Users{XyUserId: xyUserId}).Scan(&user); err != nil {
|
if err := dao.Users.Ctx(ctx).Where(do.Users{XyUserId: xyUserId}).Scan(&user); err != nil {
|
||||||
return nil, ecode.Fail.Sub("查找用户失败")
|
return nil, ecode.Fail.Sub("查找用户失败")
|
||||||
}
|
}
|
||||||
userId = user.Id
|
userId = user.Id
|
||||||
|
if user.WxOpenId != "" && user.WxOpenId != in.OpenId {
|
||||||
|
return nil, ecode.Fail.Sub("当前微信已绑定其他微信号")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind in.OpenId and update last login store ID
|
||||||
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{
|
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{
|
||||||
WxOpenId: in.OpenId,
|
WxOpenId: in.OpenId,
|
||||||
LastLoginAt: gtime.Now(),
|
LastLoginAt: gtime.Now(),
|
||||||
|
|||||||
Reference in New Issue
Block a user