@@ -214,11 +214,14 @@ protected function handleCaptchaResolutionForm(string $ip)
214
214
$ this ->getPostedVariable ('phrase ' ),
215
215
$ ip )) {
216
216
// User has correctly fill the captcha
217
-
218
217
$ this ->setSessionVariable ('crowdsec_captcha_has_to_be_resolved ' , false );
219
218
$ this ->unsetSessionVariable ('crowdsec_captcha_phrase_to_guess ' );
220
219
$ this ->unsetSessionVariable ('crowdsec_captcha_inline_image ' );
221
220
$ this ->unsetSessionVariable ('crowdsec_captcha_resolution_failed ' );
221
+ $ redirect = $ this ->getSessionVariable ('crowdsec_captcha_resolution_redirect ' )??'/ ' ;
222
+ $ this ->unsetSessionVariable ('crowdsec_captcha_resolution_redirect ' );
223
+ header ("Location: $ redirect " );
224
+ exit (0 );
222
225
} else {
223
226
// The user failed to resolve the captcha.
224
227
$ this ->setSessionVariable ('crowdsec_captcha_resolution_failed ' , true );
@@ -237,6 +240,9 @@ protected function handleCaptchaRemediation($ip)
237
240
$ this ->storeNewCaptchaCoupleInSession ();
238
241
$ this ->setSessionVariable ('crowdsec_captcha_has_to_be_resolved ' , true );
239
242
$ this ->setSessionVariable ('crowdsec_captcha_resolution_failed ' , false );
243
+ $ this ->setSessionVariable ('crowdsec_captcha_resolution_redirect ' , 'POST ' === $ this ->getHttpMethod () &&
244
+ !empty ($ _SERVER ['HTTP_REFERER ' ]) ?
245
+ $ _SERVER ['HTTP_REFERER ' ] : $ _SERVER ['REQUEST_URI ' ]);
240
246
}
241
247
242
248
// Display captcha page if this is required.
0 commit comments