本文整理匯總了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
}
示例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
}
示例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")
}
}
示例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")
}
}
示例5: GetCSS
func GetCSS(ctx *web.Context) (css string, ok bool) {
css, ok = ctx.GetSecureCookie("css")
return
}
示例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
}
示例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>",
}
}