Beispiel #1
0
func testRegister() {
	m := member.ValueMember{
		Usr:      "******",
		Pwd:      "test",
		Name:     "测试员",
		Sex:      1,
		Avatar:   "",
		Birthday: "1988-11-09",
		Phone:    "18616999822",
		Address:  "",
		Qq:       "",
		Email:    "",
		RegIp:    "127.0.0.1",
	}
	b, err := goclient.Member.Register(&m, 101, 0, "")
	if err != nil {
		jsv.LogErr(err)

	} else {
		jsv.Println("注册成功")
	}
	b, _, _ = goclient.Member.Login(m.Usr, m.Pwd)
	if b {
		jsv.Println("登录成功")
	} else {

		jsv.Printf("登录失败:Usr:%s,Pwd:%s\n", m.Usr, m.Pwd)
	}
}
Beispiel #2
0
//登录验证
func (this *Member) Login(m *jsv.Args, r *dto.MemberLoginResult) error {
	usr, pwd := (*m)["usr"].(string), (*m)["pwd"].(string)
	partnerId, _ := strconv.Atoi((*m)["partner_id"].(string))
	b, e, err := dps.MemberService.Login(partnerId, usr, pwd)
	r.Result = b
	if b {
		md5 := strings.ToLower(crypto.Md5([]byte(time.Now().String())))
		rds := Redis().Get()
		rds.Do("SETEX", fmt.Sprintf("dps:session:m%d", e.Id), 3600*3, md5)

		if jsv.Context.Debug() {
			jsv.Printf("[Member][Login]%d -- %s", e.Id, md5)
		}
		rds.Close()
		e.DynamicToken = md5
		r.Member = e
	}
	if err != nil {
		r.Message = err.Error()
	}
	return nil
}