diff --git a/common/pages.go b/common/pages.go index 737ad80b..ff97fc37 100644 --- a/common/pages.go +++ b/common/pages.go @@ -59,13 +59,13 @@ type HScript struct { func (h *Header) getScript(name string) HScript { if name[0] == '/' && name[1] == '/' { - } else { - file, ok := StaticFiles.GetShort(name) - if ok { - return HScript{file.OName,file.Sha256I} - } + } else { + file, ok := StaticFiles.GetShort(name) + if ok { + return HScript{file.OName, file.Sha256I} } - return HScript{name,""} + } + return HScript{name, ""} } func (h *Header) AddScript(name string) { @@ -243,10 +243,25 @@ type IPSearchPage struct { IP string } +// WIP: Optional anti-bot methods +type RegisterVerifyImageGridImage struct { + Src string +} +type RegisterVerifyImageGrid struct { + Question string + Items []RegisterVerifyImageGridImage +} +type RegisterVerify struct { + NoScript bool + + Image *RegisterVerifyImageGrid +} + type RegisterPage struct { *Header RequireEmail bool Token string + Verify []RegisterVerify } type Account struct { diff --git a/langs/english.json b/langs/english.json index 4e96694c..e8913152 100644 --- a/langs/english.json +++ b/langs/english.json @@ -525,6 +525,7 @@ "register_account_password":"Password", "register_account_confirm_password":"Confirm Password", "register_account_anti_spam":"Are you a spambot?", + "register_account_verify_image":"Verify Image", "register_submit_button":"Create Account", "password_reset_head":"Password Reset", diff --git a/routes/account.go b/routes/account.go index 54ca9cf3..124afd3a 100644 --- a/routes/account.go +++ b/routes/account.go @@ -200,12 +200,12 @@ func AccountRegister(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Hea token = hex.EncodeToString(h.Sum(nil)) } - return renderTemplate("register", w, r, h, c.RegisterPage{h, h.Settings["activation_type"] != 2, token}) + return renderTemplate("register", w, r, h, c.RegisterPage{h, h.Settings["activation_type"] != 2, token, nil}) } func isNumeric(data string) (numeric bool) { - for _, char := range data { - if char < 48 || char > 57 { + for _, ch := range data { + if ch < 48 || ch > 57 { return false } } @@ -384,11 +384,12 @@ func accountEditHead(titlePhrase string, w http.ResponseWriter, r *http.Request, func AccountEdit(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header) c.RouteError { accountEditHead("account", w, r, u, h) - if r.FormValue("avatar_updated") == "1" { + switch { + case r.FormValue("avatar_updated") == "1": h.AddNotice("account_avatar_updated") - } else if r.FormValue("name_updated") == "1" { + case r.FormValue("name_updated") == "1": h.AddNotice("account_name_updated") - } else if r.FormValue("mfa_setup_success") == "1" { + case r.FormValue("mfa_setup_success") == "1": h.AddNotice("account_mfa_setup_success") } @@ -602,7 +603,6 @@ func AccountEditMFADisableSubmit(w http.ResponseWriter, r *http.Request, u *c.Us } else if err == sql.ErrNoRows { return c.LocalError("You don't have two-factor enabled on your account", w, r, u) } - err = mfaItem.Delete() if err != nil { return c.InternalError(err, w, r) diff --git a/templates/register.html b/templates/register.html index 7fe78a42..71272d0c 100644 --- a/templates/register.html +++ b/templates/register.html @@ -28,6 +28,7 @@ + {{range .Verify}}{{template "register_verify.html" .}}{{end}}
diff --git a/templates/register_verify.html b/templates/register_verify.html new file mode 100644 index 00000000..a70d7b42 --- /dev/null +++ b/templates/register_verify.html @@ -0,0 +1,11 @@ +{{if .NoScript}}{{end}} \ No newline at end of file