File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <a name =" 1.0.1 " ></a >
2+ # [ 1.0.1] ( https://github.com/atomastic/csrf ) (2021-02-09)
3+ * fix issue with token generation
4+
15<a name =" 1.0.0 " ></a >
26# [ 1.0.0] ( https://github.com/atomastic/csrf ) (2021-02-08)
37* Initial release
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ class Csrf
3838 * @throws CsrfException
3939 */
4040 public function __construct (
41- string $ tokenNamePrefix = '__csrf_name ' ,
42- string $ tokenValuePrefix = '__csrf_value ' ,
41+ string $ tokenNamePrefix = '__csrf_token ' ,
42+ string $ tokenValuePrefix = '' ,
4343 int $ strength = 32
4444 ) {
4545 if ($ strength < 32 ) {
@@ -53,14 +53,14 @@ public function __construct(
5353 );
5454 }
5555
56- $ this ->tokenName = $ tokenNamePrefix . $ this ->getRandomValue ($ strength );
57- $ this ->tokenValue = $ tokenValuePrefix . $ this ->getRandomValue ($ strength );
56+ $ this ->tokenName = $ tokenNamePrefix ;
5857
59- if (array_key_exists ($ this ->tokenName , $ _SESSION )) {
60- return ;
58+ if (isset ($ _SESSION [$ this ->tokenName ])) {
59+ $ this ->tokenValue = $ _SESSION [$ this ->tokenName ];
60+ } else {
61+ $ this ->tokenValue = $ tokenValuePrefix . $ this ->getRandomValue ($ strength );
62+ $ _SESSION [$ this ->tokenName ] = $ this ->tokenValue ;
6163 }
62-
63- $ _SESSION [$ this ->tokenName ] = $ this ->tokenValue ;
6464 }
6565
6666 /**
You can’t perform that action at this time.
0 commit comments