alt anti-spam experiment

add register_account_verify_image phrase
This commit is contained in:
Azareal 2020-08-15 12:44:08 +10:00
parent 7d3085ce90
commit a1d5248b45
5 changed files with 41 additions and 13 deletions

View File

@ -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 {

View File

@ -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",

View File

@ -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)

View File

@ -28,6 +28,7 @@
<option value="0">{{lang "option_no"}}</option>
</select></div>
</div>
{{range .Verify}}{{template "register_verify.html" .}}{{end}}
<div class="formrow register_button_row form_button_row">
<div class="formitem"><button name="register-button"class="formbutton">{{lang "register_submit_button"}}</button></div>
</div>

View File

@ -0,0 +1,11 @@
{{if .NoScript}}<noscript>{{end}}{{if .Image}}<div class="formrow">
<div class="formitem formlabel"><a id="verify_image_label">{{lang "register_account_verify_image"}}</a></div>
<div class="formitem">
<div class="vimage_box">
<div class="vimage_question">{{.Image.Question}}</div>
<div class="vimage_grid">
{{range .Image.Items}}<div class="vimage_image"><img src="{{.Src}}"></div>{{end}}
</div>
</div>
</div>
</div>{{end}}{{if .NoScript}}</noscript>{{end}}