Skip to content

Commit 5c55089

Browse files
committed
Changed the if statement to make it read more logical
1 parent 51e83c0 commit 5c55089

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Middleware/CsrfGuard.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* CsrfGuard
55
*
66
* This middleware provides protection from CSRF attacks
7-
87
* USAGE
98
*
109
* // Adding middleware
@@ -55,16 +54,14 @@ public function call() {
5554
*/
5655
public function check() {
5756
// Create token
58-
$env = $this->app->environment();
59-
60-
if ( "" === session_id() ){
57+
if ( session_id() === "" ){
6158
if ( ! isset( $_SESSION[ $this->key ] ) ){
6259
$_SESSION[ $this->key ] = sha1( serialize( $_SERVER ) . rand( 0, 0xffffffff ) );
6360
}
6461
} else {
6562
throw new Exception( "Session are required to use CSRF Guard" );
6663
}
67-
$token = $_SESSION[ $this -> key ];
64+
$token = $_SESSION[ $this->key ];
6865

6966
// Validate
7067
if ( in_array($this->app->request()->getMethod(), array('POST', 'PUT', 'DELETE')) ) {
@@ -80,6 +77,4 @@ public function check() {
8077
'csrf_token' => $token,
8178
));
8279
}
83-
}
84-
85-
?>
80+
}

0 commit comments

Comments
 (0)