Fix registration form
Cette révision appartient à :
Parent
80e681fad4
révision
65a2cc2d1c
2 fichiers modifiés avec 13 ajouts et 11 suppressions
|
@ -200,15 +200,17 @@ func UserRegisterPostHandler(c *gin.Context) {
|
|||
validator.ValidateForm(&b, messages)
|
||||
if !messages.HasErrors() {
|
||||
user, _ := users.CreateUser(c)
|
||||
_, err := cookies.SetLogin(c, user)
|
||||
if err != nil {
|
||||
messages.Error(err)
|
||||
}
|
||||
if b.Email != "" {
|
||||
email.SendVerificationToUser(user, b.Email)
|
||||
}
|
||||
if !messages.HasErrors() {
|
||||
staticTemplate(c, "site/static/signup_success.jet.html")
|
||||
_, err := cookies.SetLogin(c, user)
|
||||
if err != nil {
|
||||
messages.Error(err)
|
||||
}
|
||||
if b.Email != "" {
|
||||
email.SendVerificationToUser(user, b.Email)
|
||||
}
|
||||
if !messages.HasErrors() {
|
||||
staticTemplate(c, "site/static/signup_success.jet.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
func CreateUserFromRequest(registrationForm *userValidator.RegistrationForm) (*models.User, error) {
|
||||
var user = &models.User{}
|
||||
log.Debugf("registrationForm %+v\n", registrationForm)
|
||||
validator.Bind(&user, ®istrationForm)
|
||||
validator.Bind(user, registrationForm)
|
||||
if user.Email == "" {
|
||||
user.MD5 = ""
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ func CreateUserFromRequest(registrationForm *userValidator.RegistrationForm) (*m
|
|||
user.APIToken, _ = crypto.GenerateRandomToken32()
|
||||
user.APITokenExpiry = time.Unix(0, 0)
|
||||
|
||||
if models.ORM.Create(&user).Error != nil {
|
||||
if models.ORM.Create(user).Error != nil {
|
||||
return user, errors.New("user not created")
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func CreateUserFromRequest(registrationForm *userValidator.RegistrationForm) (*m
|
|||
|
||||
// CreateUser creates a user.
|
||||
func CreateUser(c *gin.Context) (*models.User, int) {
|
||||
var user *models.User
|
||||
var user = &models.User{}
|
||||
var registrationForm userValidator.RegistrationForm
|
||||
var err error
|
||||
messages := msg.GetMessages(c)
|
||||
|
|
Référencer dans un nouveau ticket