Exemplo n.º 1
0
func LoginGET(w http.ResponseWriter, r *http.Request) {
	// Display the view
	v := view.New(r)
	v.Name = "login"
	// Refill any form fields
	view.Repopulate([]string{"email"}, r.Form, v.Vars)
	v.Render(w)
}
Exemplo n.º 2
0
func RegisterGET(w http.ResponseWriter, r *http.Request) {
	// Display the view
	v := view.New(r)
	v.Name = "register"
	// Refill any form fields
	view.Repopulate([]string{"first_name", "last_name", "email"}, r.Form, v.Vars)
	v.Render(w)
}
Exemplo n.º 3
0
func ContactGET(w http.ResponseWriter, r *http.Request) {
	// Get session
	sess := session.Instance(r)

	// Display the view
	v := view.New(r)
	v.Name = "contact"

	// If the user is logged in
	if sess.Values["id"] != nil {
		// Refill any form fields
		view.Repopulate([]string{"message"}, r.Form, v.Vars)
		v.Vars["email"] = sess.Values["email"]
		v.Vars["fullname"] = fmt.Sprintf("%v %v", sess.Values["first_name"], sess.Values["last_name"])
		v.Vars["logged_in"] = true
	} else {
		// Refill any form fields
		view.Repopulate([]string{"email", "fullname", "message"}, r.Form, v.Vars)
	}

	v.Render(w)
}
Exemplo n.º 4
0
func UserEmailGET(w http.ResponseWriter, r *http.Request) {
	// Get session
	sess := session.Instance(r)

	user_id := int64(sess.Values["id"].(uint32))
	if !isVerifiedEmail(r, user_id) {
		sess.AddFlash(view.Flash{"You can't change you email again until you verify your current email.", view.FlashError})
		sess.Save(r, w)
		http.Redirect(w, r, "/", http.StatusFound)
	}

	// Display the view
	v := view.New(r)
	v.Name = "user_email"
	v.Vars["emailold"] = sess.Values["email"]

	// Refill any form fields
	view.Repopulate([]string{"email"}, r.Form, v.Vars)

	v.Render(w)
}