示例#1
0
文件: chat.go 项目: black-tech/achat
func (this *ChatController) Get() {

	ch := models.NewChatHome()

	this.Data["cookie"] = this.Ctx.Input.Cookie("achat")
	this.Data["online_count"] = ch.GetOnlineCount()
	this.Data["waitting_count"] = ch.GetWaittingCount()
	this.Data["max_online_count"] = ch.MAX_ONLINE_COUNT

	u, _ := models.NewUser("user1", "hero")
	this.Data["username"] = u.Name
	b, _ := ch.IsOnline(u.Name)
	this.Data["testData"] = b

	this.TplNames = "chat.tpl"
}
示例#2
0
文件: login.go 项目: black-tech/achat
func (this *LoginController) Post() {

	username := this.GetString("username")
	password := this.GetString("password")
	log.Println("username: "******"password: "******"User: "******" Login failed:" + err.Error())
		this.Ctx.Output.Body([]byte("{\"code\":\"error\"}"))
		return
	}
	log.Println("User: #" + user.Name + "# Login successful:")
	user.LoginSucc()
	// log.Println("UesrSalt: " + user.Salt + "UserCookie" + user.Cookie)

	// this.SetSecureCookie("achat", "username", user.Name)
	this.Ctx.Output.Cookie("achat", user.Cookie)
	// cookie:= this.Ctx.Input.Cookie("username")
	// log.Println(cookie)
	this.Ctx.Output.Body([]byte("{\"code\":\"OK\"}"))
}