本文整理匯總了Golang中github.com/ninnemana/API/models/customer.CustomerUser.ResetPass方法的典型用法代碼示例。如果您正苦於以下問題:Golang CustomerUser.ResetPass方法的具體用法?Golang CustomerUser.ResetPass怎麽用?Golang CustomerUser.ResetPass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ninnemana/API/models/customer.CustomerUser
的用法示例。
在下文中一共展示了CustomerUser.ResetPass方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ResetPassword
func ResetPassword(rw http.ResponseWriter, r *http.Request, enc encoding.Encoder) string {
var err error
email := r.FormValue("email")
custID := r.FormValue("customerID")
site := r.FormValue("site")
if email == "" {
err = errors.New("No email address provided")
apierror.GenerateError("No email address provided", err, rw, r)
return ""
}
if custID == "" {
err = errors.New("Customer ID cannot be blank")
apierror.GenerateError("Customer ID cannot be blank", err, rw, r)
return ""
}
var user customer.CustomerUser
user.Email = email
user.CustID, err = strconv.Atoi(custID)
if err != nil {
apierror.GenerateError("Trouble parsing cust ID", err, rw, r)
return ""
}
resp, err := user.ResetPass()
if err != nil || resp == "" {
apierror.GenerateError("Trouble resetting user password", err, rw, r)
return ""
}
//email
subject := "Your Password Has Been Reset"
body := `<p>Here is your new password for the ` + site + ` site.</p>
<p>Password: ` + resp + `</p><p> If you did not request this password, please contact <a href="mailto:[email protected]">Web Support</a></p>
<p>Thanks, </p>
<p>The Ecommerce Developer Team</P>`
err = emailHelper.Send([]string{email}, subject, body, true)
if err != nil {
apierror.GenerateError("Trouble emailing new user password", err, rw, r)
return ""
}
return encoding.Must(enc.Encode("success"))
}