本文整理匯總了Golang中github.com/ovh/tat/models.User.Fullname方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Fullname方法的具體用法?Golang User.Fullname怎麽用?Golang User.Fullname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ovh/tat/models.User
的用法示例。
在下文中一共展示了User.Fullname方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Create
// Create a new user, record Username, Fullname and Email
// A mail is sent to ask user for validation
func (u *UsersController) Create(ctx *gin.Context) {
var userJSON userCreateJSON
ctx.Bind(&userJSON)
var userIn models.User
userIn.Username = u.computeUsername(userJSON)
userIn.Fullname = strings.TrimSpace(userJSON.Fullname)
userIn.Email = strings.TrimSpace(userJSON.Email)
callback := strings.TrimSpace(userJSON.Callback)
if len(userIn.Username) < 3 || len(userIn.Fullname) < 3 || len(userIn.Email) < 7 {
err := fmt.Errorf("Invalid username (%s) or fullname (%s) or email (%s)", userIn.Username, userIn.Fullname, userIn.Email)
AbortWithReturnError(ctx, http.StatusInternalServerError, err)
return
}
err := u.checkAllowedDomains(userJSON)
if err != nil {
ctx.JSON(http.StatusForbidden, gin.H{"error": err.Error()})
return
}
if models.IsEmailExists(userJSON.Email) || models.IsUsernameExists(userJSON.Username) || models.IsFullnameExists(userJSON.Fullname) {
e := fmt.Errorf("Please check your username, email or fullname. If you are already registered, please reset your password")
AbortWithReturnError(ctx, http.StatusBadRequest, e)
return
}
tokenVerify, err := userIn.Insert()
if err != nil {
log.Errorf("Error while InsertUser %s", err)
ctx.AbortWithError(http.StatusInternalServerError, err)
return
}
go utils.SendVerifyEmail(userIn.Username, userIn.Email, tokenVerify, callback)
go models.WSUser(&models.WSUserJSON{Action: "create", Username: userIn.Username})
info := ""
if viper.GetBool("username_from_email") {
info = fmt.Sprintf(" Note that configuration of Tat forced your username to %s", userIn.Username)
}
ctx.JSON(http.StatusCreated, gin.H{"info": fmt.Sprintf("please check your mail to validate your account.%s", info)})
}