本文整理匯總了Golang中github.com/cagnosolutions/web.Context.Logout方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Logout方法的具體用法?Golang Context.Logout怎麽用?Golang Context.Logout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cagnosolutions/web.Context
的用法示例。
在下文中一共展示了Context.Logout方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getDocument
func getDocument(w http.ResponseWriter, r *http.Request, c *web.Context) {
if !c.CheckAuth(w, r, "driver", "/"+c.GetPathVar("slug")) {
return
}
var driver Driver
if ok := db.GetAs("driver", c.GetFromSession("id").(string), &driver); !ok {
c.SetFlash("alertError", "Error finding driver")
c.Logout()
http.Redirect(w, r, "/"+c.GetPathVar("slug"), 303)
return
}
var company Company
if ok := db.GetAs("company", c.GetFromSession("companyId").(string), &company); !ok {
c.SetFlash("alertError", "Error finding company")
c.Logout()
http.Redirect(w, r, "/"+c.GetPathVar("slug"), 303)
return
}
var document Document
if ok := db.GetAs("document", c.GetPathVar("id"), &document); !ok {
c.SetFlash("alertError", "Error finding document")
//c.Logout()
http.Redirect(w, r, "/"+c.GetPathVar("slug")+"/driver", 303)
return
}
ts.Render(w, document.Name+".tmpl", tmpl.Model{
"driver": driver,
"company": company,
"document": document,
})
}
示例2: getDriverHome
func getDriverHome(w http.ResponseWriter, r *http.Request, c *web.Context) {
if !c.CheckAuth(w, r, "driver", "/"+c.GetPathVar("slug")) {
return
}
if c.GetFromSession("slug") != c.GetPathVar("slug") {
http.Redirect(w, r, "/"+c.GetFromSession("slug").(string), 303)
}
var driver Driver
if ok := db.GetAs("driver", c.GetFromSession("id").(string), &driver); !ok {
c.SetFlash("alertError", "Error finding driver")
c.Logout()
http.Redirect(w, r, "/"+c.GetPathVar("slug"), 303)
return
}
msgK, msgV := c.GetFlash()
ts.Render(w, "driver-home.tmpl", tmpl.Model{
msgK: msgV,
"driver": driver,
"slug": c.GetPathVar("slug"),
"documents": GetDriverDocuments(driver.Id),
})
return
}
示例3: getLogout
func getLogout(w http.ResponseWriter, r *http.Request, c *web.Context) {
c.Logout()
http.Redirect(w, r, "/", 303)
}
示例4: companyLogout
// POST company logout
func companyLogout(w http.ResponseWriter, r *http.Request, c *web.Context) {
c.Logout()
http.Redirect(w, r, "/"+c.GetPathVar("slug"), 303)
}