Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

post handle now checks for t and c

Cette révision appartient à :
ayame-git 2017-05-07 17:08:45 +03:00
Parent 0131e33b7d
révision 37bd6e70d6
2 fichiers modifiés avec 13 ajouts et 5 suppressions

Voir le fichier

@ -18,7 +18,7 @@ import (
func UserRegisterFormHandler(w http.ResponseWriter, r *http.Request) {
b := form.RegistrationForm{}
modelHelper.BindValueForm(&b, r)
b.CaptchaID = captcha.GetID(r.RemoteAddr)
b.CaptchaID = captcha.GetID()
languages.SetTranslation("en-us", viewRegisterTemplate)
htv := UserRegisterTemplateVariables{b, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
err := viewRegisterTemplate.ExecuteTemplate(w, "index.html", htv)
@ -53,12 +53,14 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
func UserRegisterPostHandler(w http.ResponseWriter, r *http.Request) {
// Check same Password
if !captcha.Authenticate(captcha.Extract(r)) {
// TODO: Prettier passing of mistyoed captcha errors
http.Error(w, captcha.ErrInvalidCaptcha.Error(), 403)
return
// TODO: Prettier passing of mistyoed captcha errors
http.Error(w, captcha.ErrInvalidCaptcha.Error(), 403)
return
}
if (r.PostFormValue("password") == r.PostFormValue("password_confirm")) && (r.PostFormValue("password") != "") {
if (form.EmailValidation(r.PostFormValue("email"))) && (form.ValidateUsername(r.PostFormValue("username"))) {
if (form.EmailValidation(r.PostFormValue("email"))) &&
(form.ValidateUsername(r.PostFormValue("username"))) &&
(form.IsAgreed(r.PostFormValue("t_and_c"))) {
_, err := userService.CreateUser(w, r)
if err == nil {
b := form.RegistrationForm{}

Voir le fichier

@ -38,6 +38,12 @@ func ValidateUsername(username string) bool {
}
return true
}
func IsAgreed(t_and_c string) bool {
if t_and_c == "1" {
return true
}
return false
}
// RegistrationForm is used when creating a user.
type RegistrationForm struct {