Example #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 != "" {
		utils.RenderJSON(w, session, http.StatusOK)
	} else {
		utils.RenderJSON(w, err, http.StatusOK)
	}
}
Example #2
0
func Comfirmation(c web.C, w http.ResponseWriter, r *http.Request) {
	user := controllers.User{}
	user.VerifiedToken = r.FormValue("verifiedtoken")
	errr := user.ComfirmAccount()
	if strings.Compare(errr.Status, "KO") == 0 {
		utils.RenderJSON(w, errr, http.StatusOK)
	} else {
		utils.RenderOk(w)
	}
}
Example #3
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)
}
Example #4
0
func Signup(c web.C, w http.ResponseWriter, r *http.Request) {
	user := controllers.User{}
	utils.RenderJSON(w, user.CreateAccount(r.FormValue("login"), r.FormValue("email"), r.FormValue("password"), r.FormValue("password2")), http.StatusOK)
}