本文整理匯總了Golang中github.com/ninnemana/API/models/customer.CustomerUser.AuthenticateUser方法的典型用法代碼示例。如果您正苦於以下問題:Golang CustomerUser.AuthenticateUser方法的具體用法?Golang CustomerUser.AuthenticateUser怎麽用?Golang CustomerUser.AuthenticateUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ninnemana/API/models/customer.CustomerUser
的用法示例。
在下文中一共展示了CustomerUser.AuthenticateUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AuthenticateUser
//Post - Form Authentication
func AuthenticateUser(rw http.ResponseWriter, r *http.Request, enc encoding.Encoder) string {
var err error
user := customer.CustomerUser{
Email: r.FormValue("email"),
Password: r.FormValue("password"),
}
if err = user.AuthenticateUser(); err != nil {
apierror.GenerateError("Trouble authenticating customer user", err, rw, r)
return ""
}
if err = user.GetLocation(); err != nil {
apierror.GenerateError("Trouble getting customer user location", err, rw, r)
return ""
}
if err = user.GetKeys(); err != nil {
apierror.GenerateError("Trouble getting customer user API keys", err, rw, r)
return ""
}
user.GetComnetAccounts()
var key string
if len(user.Keys) != 0 {
key = user.Keys[0].Key
}
cust, err := user.GetCustomer(key)
if err != nil {
apierror.GenerateError("Trouble getting customer user", err, rw, r)
return ""
}
return encoding.Must(enc.Encode(cust))
}