File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,11 @@ public function validate()
173
173
$ this ->shouldValidate = false ;
174
174
175
175
if (csrf (R::postData (self ::CSRF_FIELD )) !== true ) {
176
- throw new TokenMismatchException ('The CSRF token was invalid. ' );
176
+ if (Config::get ('debug ' ) === true ) {
177
+ throw new TokenMismatchException ('The CSRF token was invalid. ' );
178
+ }
179
+
180
+ $ this ->fail ();
177
181
}
178
182
179
183
if (parent ::validates ()) {
Original file line number Diff line number Diff line change 2
2
3
3
namespace Uniform \Tests ;
4
4
5
+ use C as Config ;
5
6
use Uniform \Form ;
6
7
use Jevets \Kirby \Flash ;
7
8
use Uniform \Guards \Guard ;
@@ -16,6 +17,7 @@ class FormTest extends TestCase
16
17
public function setUp ()
17
18
{
18
19
parent ::setUp ();
20
+ Config::set ('debug ' , true );
19
21
$ this ->form = new FormStub ;
20
22
}
21
23
@@ -35,6 +37,19 @@ public function testValidateCsrfException()
35
37
$ this ->form ->validate ();
36
38
}
37
39
40
+ public function testValidateCsrfExceptionNoDebug ()
41
+ {
42
+ Config::set ('debug ' , false );
43
+
44
+ try {
45
+ $ this ->form ->validate ();
46
+ $ this ->assertFalse ($ this ->form ->success ());
47
+ $ this ->assertFalse (true );
48
+ } catch (Exception $ e ) {
49
+ $ this ->assertEquals ('Redirected ' , $ e ->getMessage ());
50
+ }
51
+ }
52
+
38
53
public function testValidateCsrfSuccess ()
39
54
{
40
55
$ _POST ['csrf_token ' ] = csrf ();
You can’t perform that action at this time.
0 commit comments