userId := r.FormValue(":id")
	var user User
	db.Get("user", userId, &user)

	if user.Auth != r.FormValue("a") || userId != user.Id || !user.Active || user.PaypalEmail == "" {
		//fmt.Printf("Auth: %s : %s\n", user.Auth, r.FormValue("a"))
		//fmt.Printf("Id: %s : %s\n", userId, user.Id)
		//fmt.Printf("Active: %v\n", user.Active)
		//fmt.Printf("PaypalEmail: %s\n", user.PaypalEmail)
		http.Redirect(w, r, "https://zoomenvelopes.com", 303)
	}

	resp, err := http.Get(ZOOM + "/portal/stocks")
	if err != nil {
		log.Println(err)
		tmpl.Render(w, r, "home.tmpl", web.Model{"alertError": "Error getting stocks"})
		return
	}

	defer resp.Body.Close()
	b, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		log.Println(err)
		tmpl.Render(w, r, "home.tmpl", web.Model{"alertError": "Error getting stocks"})
		return
	}

	var stocks []Stock
	err = json.Unmarshal(b, &stocks)
Exemple #2
0
func main() {

	mux.AddRoutes(home, gallery, about, contact, services, listings, floorPlans, login, logout)

	mux.AddSecureRoutes(WEBMASTER, allFloorplans, uploadFloorplan, renameFloorplan, deleteFloorplan)

	mux.AddSecureRoutes(WEBMASTER, allListings, oneListing, addListing, saveListing, deleteListing)

	mux.AddSecureRoutes(WEBMASTER, webmaster, oneImage, uploadImage, saveImage, deleteImage)

	log.Fatal(http.ListenAndServe(":8080", mux))

}

var home = web.Route{"GET", "/", func(w http.ResponseWriter, r *http.Request) {
	tmpl.Render(w, r, "home.tmpl", web.Model{})
	return
}}

var gallery = web.Route{"GET", "/gallery", func(w http.ResponseWriter, r *http.Request) {
	images := db.GetAll("image")
	tmpl.Render(w, r, "gallery.tmpl", web.Model{
		"images": images,
		"cats":   getCategories(images),
	})
	return
}}

var about = web.Route{"GET", "/about", func(w http.ResponseWriter, r *http.Request) {
	tmpl.Render(w, r, "about.tmpl", web.Model{})
	return