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


Golang CustomerUser.ResetPass方法代碼示例

本文整理匯總了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"))
}
開發者ID:ninnemana,項目名稱:API,代碼行數:46,代碼來源:user.go


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