File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed 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
+
1
5
<a name =" 1.0.0 " ></a >
2
6
# [ 1.0.0] ( https://github.com/atomastic/csrf ) (2021-02-08)
3
7
* Initial release
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ class Csrf
38
38
* @throws CsrfException
39
39
*/
40
40
public function __construct (
41
- string $ tokenNamePrefix = '__csrf_name ' ,
42
- string $ tokenValuePrefix = '__csrf_value ' ,
41
+ string $ tokenNamePrefix = '__csrf_token ' ,
42
+ string $ tokenValuePrefix = '' ,
43
43
int $ strength = 32
44
44
) {
45
45
if ($ strength < 32 ) {
@@ -53,14 +53,14 @@ public function __construct(
53
53
);
54
54
}
55
55
56
- $ this ->tokenName = $ tokenNamePrefix . $ this ->getRandomValue ($ strength );
57
- $ this ->tokenValue = $ tokenValuePrefix . $ this ->getRandomValue ($ strength );
56
+ $ this ->tokenName = $ tokenNamePrefix ;
58
57
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 ;
61
63
}
62
-
63
- $ _SESSION [$ this ->tokenName ] = $ this ->tokenValue ;
64
64
}
65
65
66
66
/**
You can’t perform that action at this time.
0 commit comments