本文整理匯總了Golang中models.User.GetUser方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.GetUser方法的具體用法?Golang User.GetUser怎麽用?Golang User.GetUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.User
的用法示例。
在下文中一共展示了User.GetUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PostRegistration
func (rc *RegistrationController) PostRegistration(w http.ResponseWriter, r *http.Request) {
var um *models.User
decoder := json.NewDecoder(r.Body)
if err := decoder.Decode(&um); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if registered, dbUserModel := um.GetUser(um.AsanaId); registered {
http.Redirect(w, r, pathPrefix+"/login?registered=1", http.StatusMovedPermanently)
} else if dbUserModel == nil {
// Bad Asana Id. Should not have happened.
http.Error(w, "Please login with Asana to continue registration. Invalid Asana Id.", http.StatusForbidden)
} else {
// Register User (Save to db)
if ok, _ := dbUserModel.RegisterUser(um); !ok {
http.Error(w, "Error occured during registration.", http.StatusInternalServerError)
}
}
}