Exemplo n.º 1
0
func Signin(c web.C, w http.ResponseWriter, r *http.Request) {
	session := controllers.Session{}
	ipAddress, _, _ := net.SplitHostPort(r.RemoteAddr)
	err := session.CreateSession(r.FormValue("login"), r.FormValue("password"), ipAddress)
	if session.Token != "" {
		helpers.RenderJSON(w, session, http.StatusOK)
	} else {
		helpers.RenderJSON(w, err, http.StatusOK)
	}
}
Exemplo n.º 2
0
func Logout(c web.C, w http.ResponseWriter, r *http.Request) {
	session := controllers.Session{}
	session.Token = r.FormValue("token")
	utils.RenderJSON(w, session.DestroySession(), http.StatusOK)
}