Exemplo n.º 1
0
// Member session connect
func (this *mainC) Msc(ctx *web.Context) {
	form := ctx.Request.URL.Query()
	util.SetDeviceByUrlQuery(ctx, &form)

	ok, memberId := util.MemberHttpSessionConnect(ctx, func(memberId int) {
		v := ctx.Session().Get("member")
		var m *member.ValueMember
		if v != nil {
			m = v.(*member.ValueMember)
			if m.Id != memberId { // 如果会话冲突
				m = nil
			}
		}

		if m == nil {
			m = dps.MemberService.GetMember(memberId)
			ctx.Session().Set("member", m)
			ctx.Session().Save()
		}
	})

	if ok {
		ctx.Items["client_member_id"] = memberId
	}

	rtu := form.Get("return_url")
	if len(rtu) == 0 {
		rtu = "/"
	}
	ctx.Response.Header().Add("Location", rtu)
	ctx.Response.WriteHeader(302)
}
Exemplo n.º 2
0
// 切换设备
func (this *mainC) Change_device(ctx *web.Context) {
	form := ctx.Request.URL.Query()
	util.SetDeviceByUrlQuery(ctx, &form)

	toUrl := form.Get("return_url")
	if len(toUrl) == 0 {
		toUrl = ctx.Request.Referer()
		if len(toUrl) == 0 {
			toUrl = "/"
		}
	}

	ctx.Response.Header().Add("Location", toUrl)
	ctx.Response.WriteHeader(302)
}
Exemplo n.º 3
0
// Member session connect
func (this *mainC) Msc(ctx *web.Context) {
	form := ctx.Request.URL.Query()
	util.SetDeviceByUrlQuery(ctx, &form)

	ok, memberId := util.MemberHttpSessionConnect(ctx, func(memberId int) {
		if ctx.Session().Get("member") == nil {
			m := dps.MemberService.GetMember(memberId)
			ctx.Session().Set("member", m)
		}
	})

	if ok {
		ctx.Items["client_member_id"] = memberId
	}

	rtu := form.Get("return_url")
	if len(rtu) == 0 {
		rtu = "/"
	}
	ctx.ResponseWriter.Header().Add("Location", rtu)
	ctx.ResponseWriter.WriteHeader(302)
}