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


Golang Context.GetSecureCookie方法代碼示例

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


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

示例1: checkGodLevel

func checkGodLevel(ctx *web.Context) bool {
	godlevel, _ := ctx.GetSecureCookie("godlevel")
	godlevel = godHash(godlevel)
	if godlevel == admin_pass {
		return true
	}
	return false
}
開發者ID:youngking,項目名稱:fettemama,代碼行數:8,代碼來源:admin.go

示例2: index

func index(ctx *web.Context) string {
	cookie, ok := ctx.GetSecureCookie(cookieName)
	var top string
	if !ok {
		top = fmt.Sprintf(notice, "The cookie has not been set")
	} else {
		var val = html.EscapeString(cookie)
		top = fmt.Sprintf(notice, "The value of the cookie is '"+val+"'.")
	}
	return top + form
}
開發者ID:hoisie,項目名稱:web,代碼行數:11,代碼來源:secure_cookie.go

示例3: updateArt

// Update database for articles and render main page
func updateArt(wr *web.Context) {
	loginUser, err := wr.GetSecureCookie("user")
	if err {
		log.Println("DEBUG User logged updating article: ", loginUser)
		jailgo.Updateart(wr.Params["title"], wr.Params["description"])

		// Redirect to the main page which will show the specified art
		wr.Redirect(303, "/jail")

		// We could show this art directly using show(wr, art_num)
		// but see: http://en.wikipedia.org/wiki/Post/Redirect/Get
	} else {
		wr.Redirect(303, "/jail?check=err")
	}
}
開發者ID:elbing,項目名稱:jailblog,代碼行數:16,代碼來源:jailBlogController.go

示例4: admin

func admin(wr *web.Context) {
	loginUser, err := wr.GetSecureCookie("user")
	if err == true && loginUser != "off" {

		// Log username to control and render Admin page
		log.Println("DEBUG User logged accessing administration: ", loginUser)
		adminshow.Exec(wr)
		getdeleteart(wr)
		adminshow2.Exec(wr)
		getalldeletentry(wr)
		adminshow3.Exec(wr)
		check := ""
		foot1.Exec(wr, ViewCtxLogin{BlogLogin(wr, check), vinfo()})
		last(wr)
		foot2.Exec(wr)
	} else {
		wr.Redirect(303, "/jail?check=err")
	}
}
開發者ID:elbing,項目名稱:jailblog,代碼行數:19,代碼來源:jailBlogAdmin.go

示例5: GetCSS

func GetCSS(ctx *web.Context) (css string, ok bool) {
	css, ok = ctx.GetSecureCookie("css")
	return
}
開發者ID:youngking,項目名稱:fettemama,代碼行數:4,代碼來源:css.go

示例6: LoggedIn

func (sm *SessionManager) LoggedIn(ctx *web.Context) bool {
	if id, ok := ctx.GetSecureCookie("TDB-user"); ok && sm.SessionExists(id) {
		return true
	}
	return false
}
開發者ID:JanSichula,項目名稱:coconut,代碼行數:6,代碼來源:session.go

示例7: BlogLogin

func BlogLogin(wr *web.Context, check string) *LoginBox {
	if check != "" {
		if check == "err" {
			return &LoginBox{
				Invalid:    "<p><font color='#FF0000'><b>INVALID USER</b></font></p>",
				Userid:     "<p>User:  <input maxlength='15' size='16' name='username'></input></p>",
				Passwordid: "<p>Password: <input maxlength='10' size='13' type='password' name='password'></input></p>",
				InputLogin: "<p><input name='submit' value='Login' type='submit'></input>",
				InputReset: "<input type='reset'></input></p>",
			}
		} else if check == "ok" {
			loginUser, err := wr.GetSecureCookie("user")

			// check cookie if you logout and backward in your browser
			if err && loginUser != "off" {
				log.Println("DEBUG Login check Secure Cookie: ", loginUser)
				return &LoginBox{
					Invalid:    "<p><input name='logout' value='on' type='hidden'></p>",
					Userid:     "<p>You are logged as: " + loginUser + "</p>",
					Passwordid: "",
					InputLogin: "<p><input name='submit' value='Logout' type='submit'></p>",
					InputReset: "<p><li><a href='admin'>Administration</a></li></p>",
				}
			} else {

				// You logged out or trying to pass check=ok by hand
				return &LoginBox{
					Invalid:    "<p><font color='#FF0000'><b>INVALID USER</b></font></p>",
					Userid:     "<p>User:  <input maxlength='15' size='16' name='username'></input></p>",
					Passwordid: "<p>Password: <input maxlength='10' size='13' type='password' name='password'></input></p>",
					InputLogin: "<p><input name='submit' value='Login' type='submit'></input>",
					InputReset: "<input type='reset'></input></p>",
				}
			}
		} else if check == "out" {
			return &LoginBox{
				Invalid:    "<p><font color='#FF0000'><b>Logout</b></font></p>",
				Userid:     "<p>User:  <input maxlength='15' size='16' name='username'></input></p>",
				Passwordid: "<p>Password: <input maxlength='10' size='13' type='password' name='password'></input></p>",
				InputLogin: "<p><input name='submit' value='Login' type='submit'></input>",
				InputReset: "<input type='reset'></input></p>",
			}
		}
	}

	// Trying to look for if you're already logged
	loginUser, err := wr.GetSecureCookie("user")
	if err && loginUser != "off" {
		log.Println("DEBUG Login check Secure Cookie: ", loginUser)
		return &LoginBox{
			Invalid:    "<p><input name='logout' value='on' type='hidden'></p>",
			Userid:     "<p>You are logged as: " + loginUser + "</p>",
			Passwordid: "",
			InputLogin: "<p><input name='submit' value='Logout' type='submit'></p>",
			InputReset: "<p><li><a href='admin'>Administration</a></li></p>",
		}
	} else {
		return &LoginBox{
			Userid:     "<p>User:  <input maxlength='15' size='16' name='username'></input></p>",
			Passwordid: "<p>Password: <input maxlength='10' size='13' type='password' name='password'></input></p>",
			InputLogin: "<p><input name='submit' value='Login' type='submit'></input>",
			InputReset: "<input type='reset'></input></p>",
		}
	}

	// Default (It can only be succeded one time at primary load of index)
	return &LoginBox{
		Userid:     "<p>User:  <input maxlength='15' size='16' name='username'></input></p>",
		Passwordid: "<p>Password: <input maxlength='10' size='13' type='password' name='password'></input></p>",
		InputLogin: "<p><input name='submit' value='Login' type='submit'></input>",
		InputReset: "<input type='reset'></input></p>",
	}
}
開發者ID:elbing,項目名稱:jailblog,代碼行數:73,代碼來源:jailBlogLogin.go


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