本文整理汇总了Golang中github.com/daemonl/go_gsd/shared.IRequest.PostValueString方法的典型用法代码示例。如果您正苦于以下问题:Golang IRequest.PostValueString方法的具体用法?Golang IRequest.PostValueString怎么用?Golang IRequest.PostValueString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/daemonl/go_gsd/shared.IRequest
的用法示例。
在下文中一共展示了IRequest.PostValueString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: HandleSetPassword
func (lilo *basicLoginLogout) HandleSetPassword(r shared.IRequest) (shared.IResponse, error) {
doErr := func(err error) (shared.IResponse, error) {
log.Println(err)
r.Session().AddFlash("error", "Something went wrong...")
return getRedirectResponse("/set_password")
}
currentPassword := r.PostValueString("current_password")
newPassword1 := r.PostValueString("new_password_1")
newPassword2 := r.PostValueString("new_password_2")
if newPassword1 != newPassword2 {
r.Session().AddFlash("error", "Passwords didn't match")
return getRedirectResponse("/set_password")
}
if len(currentPassword) < 1 {
// Is user exempt?
//if !r.Session().shared.IUser().SetOnNextLogin {
// r.Session.AddFlash("error", "Incorrect current password")
// r.Redirect("/set_password")
// return
//}
} else {
//Check Current Password
matches, err := r.Session().User().CheckPassword(currentPassword)
if err != nil {
return doErr(err)
}
if !matches {
r.Session().AddFlash("error", "Incorrect current password")
return getRedirectResponse("/set_password")
}
}
/// Is it secure enough?
// TODO:... something useful.
if len(newPassword1) < 5 {
r.Session().AddFlash("error", "Password must be at least 5 characters long")
return getRedirectResponse("/set_password")
}
hashed := HashPassword(newPassword1)
db := lilo.db
_, err := db.Exec(`UPDATE `+lilo.usersTable+` SET `+lilo.ColPassword+` = ?, `+lilo.ColSetOnNextLogin+` = 0 WHERE `+lilo.ColId+` = ?`, hashed, r.Session().UserID())
if err != nil {
return doErr(err)
}
return getRedirectResponse("/app.html")
}
示例2: HandleLogin
func (lilo *basicLoginLogout) HandleLogin(request shared.IRequest) (shared.IResponse, error) {
username := request.PostValueString("username")
password := request.PostValueString("password")
lilo.doLogin(request, false, lilo.ColUsername, username, password)
return nil, nil
}