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) } }
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) } }
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) }
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) }