Ejemplo n.º 1
0
// 登陆
func (this *memberService) Login(partnerId int, usr, pwd string) (bool, *member.ValueMember, error) {
	val := this._memberRep.GetMemberValueByUsr(usr)
	if val == nil {
		return false, nil, errors.New("会员不存在")
	}

	if val.Pwd != domain.Md5MemberPwd(usr, pwd) {
		return false, nil, errors.New("会员用户或密码不正确")
	}

	if val.State == 0 {
		return false, nil, errors.New("会员已停用")
	}

	m, _ := this._memberRep.GetMember(val.Id)
	rl := m.GetRelation()

	if partnerId != -1 && rl.RegisterPartnerId != partnerId {
		return false, nil, errors.New("无法登陆:NOT MATCH PARTNER!")
	}

	val.LastLoginTime = time.Now().Unix()
	this._memberRep.SaveMember(val)

	return true, val, nil
}
Ejemplo n.º 2
0
func (this *UserC) PostRegisterInfo_post(ctx *web.Context) {
	ctx.Request.ParseForm()
	var member member.ValueMember
	web.ParseFormToEntity(ctx.Request.Form, &member)
	if i := strings.Index(ctx.Request.RemoteAddr, ":"); i != -1 {
		member.RegIp = ctx.Request.RemoteAddr[:i]
	}

	var memberId int
	var err error

	if len(member.Usr) == 0 || len(member.Pwd) == 0 {
		err = errors.New("注册信息不完整")
	} else {
		member.Pwd = domain.Md5MemberPwd(member.Usr, member.Pwd)
		memberId, err = dps.MemberService.SaveMember(&member)
		if err == nil {
			invId := dps.MemberService.GetMemberIdByInvitationCode(ctx.Request.FormValue("inviCode"))
			err = dps.MemberService.SaveRelation(memberId, "", invId,
				this.BaseC.GetPartnerId(ctx))
		}
	}

	if err != nil {
		this.BaseC.ResultOutput(ctx, gof.Message{Message: "注册失败!错误:" + err.Error()})
	} else {
		this.BaseC.ResultOutput(ctx, gof.Message{Result: true})
	}
}
Ejemplo n.º 3
0
func (this *Partner) RegisterMember(m *jsv.Args, r *jsv.Result) error {

	var err error

	e := member.ValueMember{}

	if err = jsv.UnmarshalMap((*m)["json"], &e); err != nil {
		return err
	}
	var cardId string
	var tgId int
	var partnerId int

	cardId = (*m)["card_id"].(string)
	tgId, _ = strconv.Atoi((*m)["tg_id"].(string))
	partnerId, _ = strconv.Atoi((*m)["partner_id"].(string))

	//如果卡片ID为空时,自动生成
	if cardId == "" {
		cardId = time.Now().Format("200601021504")
	}
	e.RegFrom = "WEB"

	e.Pwd = domain.Md5MemberPwd(e.Usr, e.Pwd)
	id, err := dps.MemberService.SaveMember(&e)

	if err == nil {
		dps.MemberService.SaveRelation(id, cardId, tgId, partnerId)
		r.Result = true
		return nil
	}
	return err
}
Ejemplo n.º 4
0
Archivo: test.go Proyecto: honj51/go2o
func main() {

	fmt.Println(domain.Md5PartnerPwd("wzo2o", "12345"))

	fmt.Println(domain.NewApiId(105))
	fmt.Println(domain.Md5MemberPwd("u1000", "123456"))
	fmt.Println(1 << 2)
}
Ejemplo n.º 5
0
Archivo: test.go Proyecto: xianmau/go2o
func main() {

	fmt.Println(domain.Md5PartnerPwd("wzo2o", "12345"))

	fmt.Println(domain.NewApiId(105))
	fmt.Println(domain.Md5MemberPwd("u1000", "123456"))
	fmt.Println(1 << 2)
	fmt.Println(util.IsMobileAgent("Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"))
}
Ejemplo n.º 6
0
func (this *partnerRep) doSomething() {
	ms := []*member.ValueMember{}
	orm := this.Connector.GetOrm()
	orm.Select(&ms, "1=1")

	for _, v := range ms {
		v.Pwd = domain.Md5MemberPwd("123456")
		orm.Save(v.Id, v)
	}
}
Ejemplo n.º 7
0
// 修改密码,旧密码可为空
func (this *Member) ModifyPassword(newPwd, oldPwd string) error {
	var err error

	if b, err := domain.ChkPwdRight(newPwd); !b {
		return err
	}

	if len(oldPwd) != 0 {
		dyp := domain.Md5MemberPwd(oldPwd)
		if dyp != this._value.Pwd {
			return errors.New("原密码不正确")
		}
	}

	this._value.Pwd = domain.Md5MemberPwd(newPwd)
	_, err = this.Save()

	return err
}
Ejemplo n.º 8
0
// 修改密码,旧密码可为空
func (this *Member) ModifyPassword(newPwd, oldPwd string) error {
	var err error

	if newPwd == oldPwd {
		return member.ErrPwdCannotSame
	}

	if b, err := domain.ChkPwdRight(newPwd); !b {
		return err
	}

	if len(oldPwd) != 0 {
		dyp := domain.Md5MemberPwd(oldPwd)
		if dyp != this._value.Pwd {
			return member.ErrPwdPldPwdNotRight
		}
	}

	this._value.Pwd = domain.Md5MemberPwd(newPwd)
	_, err = this.Save()

	return err
}
Ejemplo n.º 9
0
func main() {

	fmt.Println(domain.Md5PartnerPwd("wzo2o", "12345"))

	fmt.Println(domain.NewApiId(105))
	fmt.Println(domain.Md5MemberPwd("123456"))
	fmt.Println(1 << 2)
	fmt.Println(util.IsMobileAgent("Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"))

	tagRegexp := regexp.MustCompile("\\s*([^:\\|]+):([^:\\|]+)\\s*\\|*")
	matches := tagRegexp.FindAllStringSubmatch("G1:10|G2:12|G3:14", -1)
	for i := 0; i < len(matches); i++ {
		fmt.Println(i, "---", matches[i][1], matches[i][2])
	}
}
Ejemplo n.º 10
0
// 注册
func (this *MemberC) Register(ctx *web.Context) {
	if this.BaseC.Requesting(ctx) {
		r := ctx.Request
		var result dto.MessageResult

		var partnerId int = this.GetPartnerId(ctx)
		var invMemberId int // 邀请人
		var usr string = r.FormValue("usr")
		var pwd string = r.FormValue("pwd")
		var registerFrom string = r.FormValue("reg_from")          // 注册来源
		var invitationCode string = r.FormValue("invitation_code") // 推荐码
		var regIp string
		if i := strings.Index(r.RemoteAddr, ":"); i != -1 {
			regIp = r.RemoteAddr[:i]
		}

		fmt.Println(usr, pwd, "REGFROM:", registerFrom, "INVICODE:", invitationCode)

		// 检验
		if len(invitationCode) != 0 {
			invMemberId = dps.MemberService.GetMemberIdByInvitationCode(invitationCode)
			if invMemberId == 0 {
				result.Message = "推荐/邀请人不存在!"
				ctx.Response.JsonOutput(result)
				return
			}
		}

		var member member.ValueMember
		member.Usr = usr
		member.Pwd = domain.Md5MemberPwd(pwd)
		member.RegIp = regIp
		member.RegFrom = registerFrom

		memberId, err := dps.MemberService.SaveMember(&member)
		if err == nil {
			result.Result = true
			err = dps.MemberService.SaveRelation(memberId, "-", invMemberId, partnerId)
		}

		if err != nil {
			result.Message = err.Error()
		}

		ctx.Response.JsonOutput(result)
	}
}
Ejemplo n.º 11
0
func (this *memberService) Login(usr, pwd string) (bool, *member.ValueMember, error) {
	val := this._memberRep.GetMemberValueByUsr(usr)
	if val == nil {
		return false, nil, errors.New("会员不存在")
	}

	if val.Pwd != domain.Md5MemberPwd(usr, pwd) {
		return false, nil, errors.New("会员用户或密码不正确")
	}

	if val.State == 0 {
		return false, nil, errors.New("会员已停用")
	}

	val.LastLoginTime = time.Now().Unix()
	this._memberRep.SaveMember(val)

	return true, val, nil
}