當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.CheckAuth方法代碼示例

本文整理匯總了Golang中github.com/cagnosolutions/web.Context.CheckAuth方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.CheckAuth方法的具體用法?Golang Context.CheckAuth怎麽用?Golang Context.CheckAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cagnosolutions/web.Context的用法示例。


在下文中一共展示了Context.CheckAuth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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,
	})

}
開發者ID:gabewitmer,項目名稱:go-cns,代碼行數:32,代碼來源:temp-controllers.go

示例2: AdminDriverDocumentDelete

func AdminDriverDocumentDelete(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	service.DeleteDocument(c.GetPathVar("documentId"))
	c.SetFlash("alertSuccess", "Successfully deleted document")
	http.Redirect(w, r, "/admin/driver/"+c.GetPathVar("driverId")+"/document", 303)
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:8,代碼來源:admin-controllers.go

示例3: AdminVehicleDelete

func AdminVehicleDelete(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	service.DeleteVehicle(c.GetPathVar("vehicleId"))
	c.SetFlash("alertSuccess", "Successfuly deleted vehicle")
	http.Redirect(w, r, "/admin/vehicle", 303)
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:9,代碼來源:admin-controllers.go

示例4: AdminCompanyDelete

// POST admin delete company
func AdminCompanyDelete(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	service.DeleteCompany(c.GetPathVar("id"))
	c.SetFlash("alertSuccess", "Successfully deleted  company")
	http.Redirect(w, r, "/admin/company", 303)
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:10,代碼來源:admin-controllers.go

示例5: AdminDriverDocumentSave

func AdminDriverDocumentSave(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	document := service.FindOneDocument(r.FormValue("id"))
	document.Data = r.FormValue("data")
	service.SaveDocument(document)
	c.SetFlash("alertSuccess", "Successfully save document")
	fmt.Fprintf(w, "/admin/driver/%s/document", c.GetPathVar("driverId"))
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:10,代碼來源:admin-controllers.go

示例6: AdminHome

// GET admin home
func AdminHome(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	msgK, msgV := c.GetFlash()
	ts.Render(w, "admin-home.tmpl", tmpl.Model{
		msgK: msgV,
	})
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:11,代碼來源:admin-controllers.go

示例7: DevCommentSave

func DevCommentSave(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "developer") {
		return
	}
	comment := service.FindOneComment(c.GetPathVar("id"))
	closed, _ := strconv.ParseBool(r.FormValue("closed"))
	comment.Closed = closed
	service.SaveComment(comment)
	http.Redirect(w, r, "/dev/comment", 303)
}
開發者ID:gregpechiro,項目名稱:go-cns,代碼行數:10,代碼來源:developer.go

示例8: DevComments

func DevComments(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "developer") {
		return
	}
	msgK, msgV := c.GetFlash()
	ts.Render(w, "dev-comments.tmpl", tmpl.Model{
		msgK:       msgV,
		"comments": service.FindAllComment(),
	})
}
開發者ID:gregpechiro,項目名稱:go-cns,代碼行數:10,代碼來源:developer.go

示例9: saveDocument

// POSt driver save document
func saveDocument(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/"+c.GetPathVar("slug"), "driver") {
		return
	}
	document := service.FindOneDocument(r.FormValue("id"))
	document.Data = r.FormValue("data")
	service.SaveDocument(document)
	c.SetFlash("alertSuccess", "Successfully save document")
	fmt.Fprintf(w, "/%s/driver", c.GetPathVar("slug"))
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:11,代碼來源:document-controllers.go

示例10: AdminCompanyVehicleNew

// GET admin get new vehicle page
func AdminCompanyVehicleNew(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	msgK, msgV := c.GetFlash()
	ts.Render(w, "admin-company-vehicle-form.tmpl", tmpl.Model{
		msgK:       msgV,
		"vehicles": service.FindAllVehicleByCompany(c.GetPathVar("companyId")),
		"company":  service.FindOneCompany(c.GetPathVar("companyId")),
	})
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:12,代碼來源:admin-controllers.go

示例11: AdminCompanyNew

// GET admin new company page
func AdminCompanyNew(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	msgK, msgV := c.GetFlash()
	ts.Render(w, "admin-companies-form.tmpl", tmpl.Model{
		msgK:        msgV,
		"companies": service.FindAllCompany(),
	})
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:12,代碼來源:admin-controllers.go

示例12: AdminVehicleGetAll

// GET admin get all vehicles
func AdminVehicleGetAll(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	msgK, msgV := c.GetFlash()
	ts.Render(w, "admin-vehicle.tmpl", tmpl.Model{
		msgK:        msgV,
		"vehicles":  service.FindAllVehicle(),
		"companies": service.CompanyNames(),
	})
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:13,代碼來源:admin-controllers.go

示例13: AdminCompanyEdit

// POST admin edit company
func AdminCompanyEdit(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	r.ParseForm()
	company := service.FindOneCompany(r.FormValue("id"))
	util.FormToStruct(&company, r.Form, "")
	service.SaveCompany(company)
	c.SetFlash("alertSuccess", "Successfully saved company")
	http.Redirect(w, r, "/admin/company/"+r.FormValue("id"), 303)
	return
}
開發者ID:gregpechiro,項目名稱:go-cns,代碼行數:13,代碼來源:admin-controllers.go

示例14: AdminCompanyDriverGetAll

// GET admin get all company's drivers
func AdminCompanyDriverGetAll(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	msgK, msgV := c.GetFlash()
	ts.Render(w, "admin-company-driver.tmpl", tmpl.Model{
		msgK:      msgV,
		"drivers": service.FindAllDriverByCompany(c.GetPathVar("companyId")),
		"company": service.FindOneCompany(c.GetPathVar("companyId")),
	})
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:13,代碼來源:admin-controllers.go

示例15: AdminVehicleSave

func AdminVehicleSave(w http.ResponseWriter, r *http.Request, c *web.Context) {
	if !c.CheckAuth(w, r, "/login", "admin", "employee", "developer") {
		return
	}
	r.ParseForm()
	vehicle := service.FindOneVehicle(r.FormValue("id"))
	util.FormToStruct(&vehicle, r.Form, "")
	service.SaveVehicle(vehicle)
	c.SetFlash("alertSuccess", "Successfully saved vehicle")
	http.Redirect(w, r, "/admin/vehicle", 303)
	return
}
開發者ID:gregpechiro,項目名稱:cns,代碼行數:12,代碼來源:admin-controllers.go


注:本文中的github.com/cagnosolutions/web.Context.CheckAuth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。