Archived
1
0

revert captcha, add stuff to js

This commit is contained in:
Jeff Becker 2017-09-30 07:35:01 -04:00
parent 534e023526
commit d245462373
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 27 additions and 13 deletions

View File

@ -993,19 +993,12 @@ func (self httpFrontend) handle_poster(wr http.ResponseWriter, r *http.Request)
func (self *httpFrontend) serve_captcha(wr http.ResponseWriter, r *http.Request) {
s, err := self.store.Get(r, self.name)
if err == nil {
id, ok := s.Values["captcha_id"]
if ok {
redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, id)
s.Save(r, wr)
http.Redirect(wr, r, redirect_url, 302)
} else {
captcha_id := captcha.New()
s.Values["captcha_id"] = captcha_id
s.Save(r, wr)
redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, captcha_id)
// redirect to the image
http.Redirect(wr, r, redirect_url, 302)
}
} else {
// handle session error
// TODO: clear cookies?

View File

@ -31,7 +31,28 @@ function get_storage() {
return st;
}
function setSrcQuery(e, q) {
var src = e.src;
var p = src.indexOf('?');
if (p >= 0) {
src = src.substr(0, p);
}
e.src = src + "?" + q
}
function reload(el) {
setSrcQuery(el, "reload=" + (new Date()).getTime());
return false;
}
// captcha reload
onready(function(){
var e = document.getElementById("captcha_img");
if (e) {
e.onclick = function() {
reload(e);
};
}
});
// rewrite all images to add inline expand
onready(function() {