alt anti-spam experiment
add register_account_verify_image phrase
This commit is contained in:
parent
7d3085ce90
commit
a1d5248b45
|
@ -62,10 +62,10 @@ func (h *Header) getScript(name string) HScript {
|
||||||
} else {
|
} else {
|
||||||
file, ok := StaticFiles.GetShort(name)
|
file, ok := StaticFiles.GetShort(name)
|
||||||
if ok {
|
if ok {
|
||||||
return HScript{file.OName,file.Sha256I}
|
return HScript{file.OName, file.Sha256I}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HScript{name,""}
|
return HScript{name, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Header) AddScript(name string) {
|
func (h *Header) AddScript(name string) {
|
||||||
|
@ -243,10 +243,25 @@ type IPSearchPage struct {
|
||||||
IP string
|
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 {
|
type RegisterPage struct {
|
||||||
*Header
|
*Header
|
||||||
RequireEmail bool
|
RequireEmail bool
|
||||||
Token string
|
Token string
|
||||||
|
Verify []RegisterVerify
|
||||||
}
|
}
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
|
|
|
@ -525,6 +525,7 @@
|
||||||
"register_account_password":"Password",
|
"register_account_password":"Password",
|
||||||
"register_account_confirm_password":"Confirm Password",
|
"register_account_confirm_password":"Confirm Password",
|
||||||
"register_account_anti_spam":"Are you a spambot?",
|
"register_account_anti_spam":"Are you a spambot?",
|
||||||
|
"register_account_verify_image":"Verify Image",
|
||||||
"register_submit_button":"Create Account",
|
"register_submit_button":"Create Account",
|
||||||
|
|
||||||
"password_reset_head":"Password Reset",
|
"password_reset_head":"Password Reset",
|
||||||
|
|
|
@ -200,12 +200,12 @@ func AccountRegister(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Hea
|
||||||
token = hex.EncodeToString(h.Sum(nil))
|
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) {
|
func isNumeric(data string) (numeric bool) {
|
||||||
for _, char := range data {
|
for _, ch := range data {
|
||||||
if char < 48 || char > 57 {
|
if ch < 48 || ch > 57 {
|
||||||
return false
|
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 {
|
func AccountEdit(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header) c.RouteError {
|
||||||
accountEditHead("account", w, r, u, h)
|
accountEditHead("account", w, r, u, h)
|
||||||
if r.FormValue("avatar_updated") == "1" {
|
switch {
|
||||||
|
case r.FormValue("avatar_updated") == "1":
|
||||||
h.AddNotice("account_avatar_updated")
|
h.AddNotice("account_avatar_updated")
|
||||||
} else if r.FormValue("name_updated") == "1" {
|
case r.FormValue("name_updated") == "1":
|
||||||
h.AddNotice("account_name_updated")
|
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")
|
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 {
|
} else if err == sql.ErrNoRows {
|
||||||
return c.LocalError("You don't have two-factor enabled on your account", w, r, u)
|
return c.LocalError("You don't have two-factor enabled on your account", w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = mfaItem.Delete()
|
err = mfaItem.Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
<option value="0">{{lang "option_no"}}</option>
|
<option value="0">{{lang "option_no"}}</option>
|
||||||
</select></div>
|
</select></div>
|
||||||
</div>
|
</div>
|
||||||
|
{{range .Verify}}{{template "register_verify.html" .}}{{end}}
|
||||||
<div class="formrow register_button_row form_button_row">
|
<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 class="formitem"><button name="register-button"class="formbutton">{{lang "register_submit_button"}}</button></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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}}
|
Loading…
Reference in New Issue