本文整理汇总了Golang中sess.IsSess函数的典型用法代码示例。如果您正苦于以下问题:Golang IsSess函数的具体用法?Golang IsSess怎么用?Golang IsSess使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsSess函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SucMod
// Modifica si hay, Crea si no hay
// Requiere IdEmp. IdSuc es opcional, si no hay lo crea, si hay modifica
func SucMod(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
c.Errorf("R-EMP: %v", r.FormValue("IdEmp"))
if s, ok := sess.IsSess(w, r, c); ok {
u, _ := model.GetCta(c, s.User)
tc := make(map[string]interface{})
tc["Sess"] = s
fd, valid := sucForm(w, r, true)
empresa, err := u.GetEmpresa(c, r.FormValue("IdEmp"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
sucursal := sucFill(r)
if valid {
if empresa != nil {
newsuc, err := empresa.PutSuc(c, u, &sucursal, r.FormValue("IdEmp"))
//fmt.Fprintf(w, "IdSuc: %s", newsuc.IdSuc);
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fd = sucToForm(*newsuc)
fd.Ackn = "Ok"
}
}
fd.Entidades = model.ListEnt(c, strings.TrimSpace(r.FormValue("DirEnt")))
tc["Empresa"] = empresa
tc["FormDataSuc"] = fd
sucadmTpl.ExecuteTemplate(w, "sucursal", tc)
} else {
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
}
示例2: NewEmp
func NewEmp(w http.ResponseWriter, r *http.Request) {
// formato con validación
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
_, valid := formatoEmp(w, r, s, true)
if !valid {
return
}
u, _ := model.GetCta(c, s.User)
fe := fillEmpresa(r)
// Se añade una empresa
//e, err := u.NewEmpresa(c, &fe)
_, err := u.NewEmpresa(c, &fe)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err1 := model.PutCtaEmp(c, fe.IdEmp, u.Email, u.EmailAlt)
if err1 != nil {
http.Error(w, err1.Error(), http.StatusInternalServerError)
return
}
//formEmp(c, w, &s, e)
ShowListEmp(w, r)
} else {
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
}
示例3: micrositio
func micrositio(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
u, _ := model.GetCta(c, s.User)
emp, err := u.GetEmpresa(c, r.FormValue("IdEmp"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
img := model.GetLogo(c, r.FormValue("IdEmp"))
if img == nil {
img = new(model.Image)
img.IdEmp = emp.IdEmp
}
fd := imgToForm(*img)
tc := make(map[string]interface{})
tc["Sess"] = s
tc["Empresa"] = emp
tc["FormData"] = fd
micrositioTpl.Execute(w, tc)
}
} else {
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
}
示例4: CtaMod
func CtaMod(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
if u, err := model.GetCta(c, s.User); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else {
if fd, valid := ctaForm(w, r, s, true, ctadmTpl); !valid {
return
} else {
ctaFill(r, u)
if _, err := model.PutCta(c, u); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
tc := make(map[string]interface{})
tc["Sess"] = s
tc["FormDataCta"] = fd
ctadmTpl.ExecuteTemplate(w, "cta", tc)
}
}
} else {
http.Redirect(w, r, "/", http.StatusFound)
}
}
示例5: municipios
func municipios(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
_, ok := sess.IsSess(w, r, c)
if ok {
if item, err := memcache.Get(c, "msp_"+r.FormValue("CveEnt")); err == memcache.ErrCacheMiss {
if entidad, err := model.GetEntidad(c, r.FormValue("CveEnt")); err == nil {
if municipios, _ := entidad.GetMunicipios(c); err == nil {
b, _ := json.Marshal(municipios)
item := &memcache.Item{
Key: "msp_" + r.FormValue("CveEnt"),
Value: b,
}
if err := memcache.Add(c, item); err == memcache.ErrNotStored {
c.Infof("item with key %q already exists", item.Key)
} else if err != nil {
c.Errorf("Error memcache.Add Municipio : %v", err)
}
c.Infof("CveMun generado: %v", item.Key)
htmlComboMuns(w, municipios, r.FormValue("CveMun"))
}
}
} else {
//c.Infof("Memcache activo: %v", item.Key)
var municipios []model.Municipio
if err := json.Unmarshal(item.Value, &municipios); err != nil {
c.Errorf("error adding item: %v", err)
}
htmlComboMuns(w, &municipios, r.FormValue("CveMun"))
}
}
return
}
示例6: materiales
func materiales(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
tc := make(map[string]interface{})
tc["Sess"] = s
materialesTpl.Execute(w, tc)
} else {
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
}
示例7: modData
func modData(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
u, _ := model.GetCta(c, s.User)
emp, err := u.GetEmpresa(c, r.FormValue("IdEmp"))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
imgo := model.GetLogo(c, r.FormValue("IdEmp"))
if imgo == nil {
imgo = new(model.Image)
imgo.IdEmp = emp.IdEmp
}
fd := imgToForm(*imgo)
tc := make(map[string]interface{})
tc["Sess"] = s
tc["Empresa"] = emp
tc["FormData"] = fd
if r.Method != "POST" {
// No upload; show the upload form.
micrositio(w, r)
return
}
idemp := r.FormValue("IdEmp")
name := r.FormValue("Name")
desc := r.FormValue("Desc")
url := r.FormValue("Url")
sp1 := r.FormValue("Sp1")
sp2 := r.FormValue("Sp2")
// key := datastore.NewKey(c, "EmpLogo", r.FormValue("id"), 0, nil)
// im := new(model.Image)
// Save the image under a unique key, a hash of the image.
imgo = &model.Image{
Data: imgo.Data, IdEmp: idemp, IdImg: imgo.IdImg,
Kind: "EmpLogo", Name: name, Desc: desc,
Sizepx: 0, Sizepy: 0, Url: url, Type: "",
Sp1: sp1, Sp2: sp2, Sp3: imgo.Sp3, Sp4: imgo.Sp4,
Np1: 0, Np2: 0, Np3: 0, Np4: 0,
}
_, err = model.PutLogo(c, imgo)
if err != nil {
tc["Error"] = struct{ Cantsave string }{"cantsave"}
micrositioTpl.Execute(w, tc)
return
}
micrositio(w, r)
} else {
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
}
示例8: SucDel
func SucDel(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if _, ok := sess.IsSess(w, r, c); ok {
if err := model.DelSuc(c, r.FormValue("IdSuc")); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
ShowListSuc(w, r)
return
}
http.Redirect(w, r, "/r/sucursales", http.StatusFound)
}
示例9: descargamg
func descargamg(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if _, ok := sess.IsSess(w, r, c); ok {
// Stream de materiales
//w.Header().Set("Content-type", "application/octet-stream")
//w.Header().Set("Content-disposition", "attachment; filename=test.zip")
http.Redirect(w, r, "/ElBuenFin_Materiales.zip", http.StatusFound)
} else {
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
}
示例10: OfDel
func OfDel(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if _, ok := sess.IsSess(w, r, c); ok {
if err := model.DelOferta(c, r.FormValue("IdOft")); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
OfShowList(w, r)
return
}
http.Redirect(w, r, "/r/ofertas", http.StatusFound)
}
示例11: registro
func registro(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if _, ok := sess.IsSess(w, r, c); !ok {
var fd FormDataCta
tc := make(map[string]interface{})
//tc["Sess"] = s
tc["FormDataCta"] = fd
registroTpl.ExecuteTemplate(w, "cta", tc)
return
} else {
http.Redirect(w, r, "/r/dash", http.StatusFound)
}
}
示例12: DelEmp
func DelEmp(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
u, _ := model.GetCta(c, s.User)
if err := u.DelEmpresa(c, r.FormValue("IdEmp")); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
ShowListEmp(w, r)
return
}
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
示例13: Salir
func Salir(w http.ResponseWriter, r *http.Request) {
now := time.Now().Add(time.Duration(model.GMTADJ) * time.Second)
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
s.Expiration = now.AddDate(-1, 0, 0)
_, err := datastore.Put(c, datastore.NewKey(c, "Sess", s.User, 0, nil), &s)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
w.Header().Add("Set-Cookie", fmt.Sprintf("ebfmex-pub-sesscontrol-ua=%s; expires=%s; path=/;", "", "Thu, 18 Oct 2012 01:01:23 GMT;"))
w.Header().Add("Set-Cookie", fmt.Sprintf("ebfmex-pub-sessid-ua=%s; expires=%s; path=/;", "", "Thu, 18 Oct 2012 01:01:23 GMT;"))
http.Redirect(w, r, "/r/registro", http.StatusFound)
}
示例14: Acceso
func Acceso(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
var st sess.Sess
if _, ok := sess.IsSess(w, r, c); !ok {
//fmt.Fprintf(w, "u:%s, p:%s", r.FormValue("u"), r.FormValue("p"))
if r.FormValue("u") != "" && r.FormValue("p") != "" {
user := strings.TrimSpace(r.FormValue("u"))
pass := strings.TrimSpace(r.FormValue("p"))
/* validar usuario y pass */
if model.ValidEmail.MatchString(user) && model.ValidPass.MatchString(pass) {
q := datastore.NewQuery("Cta").Filter("Email =", user).Filter("Pass =", pass).Filter("Status =", true)
if count, _ := q.Count(c); count != 0 {
for t := q.Run(c); ; {
var g model.Cta
key, err := t.Next(&g)
if err == datastore.Done {
break
}
// Coincide contraseña, se activa una sesión
_, _, err = sess.SetSess(w, c, key, g.Email, g.Nombre)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Redireccion
http.Redirect(w, r, "/r/dash", http.StatusFound)
return
}
}
}
st.User = r.FormValue("u")
st.ErrMsg = "Usuario o contraseña incorrectos"
st.ErrClass = "show"
} else {
st.User = r.FormValue("u")
st.ErrMsg = "Proporcione usuario y contraseña"
st.ErrClass = "show"
}
} else {
// hay sesión
http.Redirect(w, r, "/r/dash", http.StatusFound)
return
}
tc := make(map[string]interface{})
tc["Sess"] = st
accesoErrorTpl.Execute(w, tc)
}
示例15: CtaShow
func CtaShow(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if s, ok := sess.IsSess(w, r, c); ok {
if g, err := model.GetCta(c, s.User); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
} else {
tc := make(map[string]interface{})
tc["Sess"] = s
tc["FormDataCta"] = ctaToForm(*g)
ctadmTpl.ExecuteTemplate(w, "cta", tc)
return
}
} else {
http.Redirect(w, r, "/", http.StatusFound)
}
}