// 检查注册信息是否正确 func (this *MemberManagerImpl) CheckPostedRegisterInfo(v *member.Member, pro *member.Profile, invitationCode string) (invitationId int, err error) { perm := this._valRep.GetRegisterPerm() //验证用户名 v.Usr = strings.TrimSpace(v.Usr) if len(v.Usr) < 6 { return 0, member.ErrUsrLength } if !userRegex.MatchString(v.Usr) { return 0, member.ErrUsrValidErr } if this._rep.CheckUsrExist(v.Usr, 0) { return 0, member.ErrUsrExist } //验证密码 v.Pwd = strings.TrimSpace(v.Pwd) if len(v.Pwd) < 6 { return 0, member.ErrPwdLength } //验证手机 pro.Phone = strings.TrimSpace(pro.Phone) l := len(pro.Phone) if perm.NeedPhone && l == 0 { return 0, member.ErrMissingPhone } if l > 0 { if !phoneRegex.MatchString(pro.Phone) { return 0, member.ErrBadPhoneFormat } if b := this._rep.CheckPhoneBind(pro.Phone, v.Id); b { return 0, member.ErrPhoneHasBind } } //验证IM pro.Im = strings.TrimSpace(pro.Im) if perm.NeedIm && len(pro.Im) == 0 { return 0, errors.New(strings.Replace(member.ErrMissingIM.Error(), "IM", variable.AliasMemberIM, -1)) } // 检查验证码 err = this.RegisterPerm(len(invitationCode) > 0) if err == nil { invitationId, err = this.checkInvitationCode(invitationCode) } return invitationId, err }
// 设置值 func (this *memberImpl) SetValue(v *member.Member) error { v.Usr = this._value.Usr if len(this._value.InvitationCode) == 0 { this._value.InvitationCode = v.InvitationCode } if v.Exp != 0 { this._value.Exp = v.Exp } if v.Level > 0 { this._value.Level = v.Level } if len(v.TradePwd) == 0 { this._value.TradePwd = v.TradePwd } return nil }