userId := web.GetSess(r, "id").(string)
	var user User
	db.Get("user", userId, &user)
	tmpl.Render(w, r, "user.tmpl", web.Model{
		"user": user,
	})
	return
}}

var updateUser = web.Route{"POST", "/user", func(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	userId := web.GetSess(r, "id").(string)
	var user User
	db.Get("user", userId, &user)
	oldPass := user.Password
	FormToStruct(&user, r.Form, "")
	if user.Password == "" {
		user.Password = oldPass
	}
	var users []User
	db.TestQuery("user", &users, adb.Eq("email", user.Email), adb.Ne("id", `"`+user.Id+`"`))
	// exist := db2.Query("user", &users, repono.C("Email", repono.EQ, user.Email), repono.C("Id", repono.NE, `"`+user.Id+`"`))
	if len(users) > 0 {
		web.SetErrorRedirect(w, r, "/user", "A user with that email already exists")
		return
	}
	db.Set("user", userId, user)
	web.SetSuccessRedirect(w, r, "/user", "Successfully updated user<br>*NOTE* &nbsp;&nbsp;&nbsp;Changing your email in the portal will NOT change it at zoomenvelopes.com")
	return
}}
	})
	return
}}

var adminSaveUser = web.Route{"POST", "/admin/user", func(w http.ResponseWriter, r *http.Request) {
	userId := r.FormValue("id")
	var user User
	if userId != "" {
		db.Get("user", userId, &user)
	}
	FormToStruct(&user, r.Form, "")
	if userId != "" {
		db.Set("user", userId, user)
	} else {
		var users []User
		db.TestQuery("user", &users, adb.Eq("zoomId", strconv.Itoa(user.ZoomId)))
		// exists := db2.Query("user", &users, repono.Eq("ZoomId", strconv.Itoa(user.ZoomId)))
		if len(users) > 0 {
			web.SetErrorRedirect(w, r, "/admin/user", "Error Zoom user is already a portal user")
			return
		}
		user.Id = strconv.Itoa(int(time.Now().UnixNano()))
		u := bpt.UUID()
		user.Auth = fmt.Sprintf("%x-%x-%x-%x-%x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:])
		user.Password = user.Email
		user.Active = true
		db.Add("user", user.Id, user)
	}
	web.SetSuccessRedirect(w, r, "/admin", "Successfully saved user")
	return
}}