예제 #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\"}"))
}