本文整理匯總了Golang中github.com/beego/wetalk/modules/models.User.IsActive方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.IsActive方法的具體用法?Golang User.IsActive怎麽用?Golang User.IsActive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/beego/wetalk/modules/models.User
的用法示例。
在下文中一共展示了User.IsActive方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Active
// Active implemented check Email actice code.
func (this *RegisterRouter) Active() {
this.TplNames = "auth/active.html"
// no need active
if this.CheckActiveRedirect(false) {
return
}
code := this.GetString(":code")
var user models.User
if auth.VerifyUserActiveCode(&user, code) {
user.IsActive = true
user.Rands = models.GetUserSalt()
if err := user.Update("IsActive", "Rands", "Updated"); err != nil {
beego.Error("Active: user Update ", err)
}
if this.IsLogin {
this.User = user
}
this.Redirect("/active/success", 302)
} else {
this.Data["Success"] = false
}
}
示例2: ResetPost
// Reset implemented user password reset.
func (this *ForgotRouter) ResetPost() {
this.TplNames = "auth/reset.html"
code := this.GetString(":code")
this.Data["Code"] = code
var user models.User
if auth.VerifyUserResetPwdCode(&user, code) {
this.Data["Success"] = true
form := auth.ResetPwdForm{}
if this.ValidFormSets(&form) == false {
return
}
user.IsActive = true
user.Rands = models.GetUserSalt()
if err := auth.SaveNewPassword(&user, form.Password); err != nil {
beego.Error("ResetPost Save New Password: ", err)
}
if this.IsLogin {
auth.LogoutUser(this.Ctx)
}
this.FlashRedirect("/login", 302, "ResetSuccess")
} else {
this.Data["Success"] = false
}
}
示例3: SaveUserProfile
func (form *ProfileForm) SaveUserProfile(user *models.User) error {
// set md5 value if the value is an email
if strings.IndexRune(form.GrEmail, '@') != -1 {
form.GrEmail = utils.EncodeMd5(form.GrEmail)
}
changes := utils.FormChanges(user, form)
if len(changes) > 0 {
// if email changed then need re-active
if user.Email != form.Email {
user.IsActive = false
changes = append(changes, "IsActive")
}
utils.SetFormValues(form, user)
return user.Update(changes...)
}
return nil
}