Skip to content

Commit 8e5ad6a

Browse files
committed
Check if CSRF token was submitted
1 parent 153a127 commit 8e5ad6a

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

includes/class.csrf.inc.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ public static function get_token() {
1818

1919
// Used to check a submitted token with a token stored in the session
2020
public static function check_token($submitted_token) {
21-
// Bring in the session variable
22-
global $session;
23-
24-
// Check if the submitted token matches the one in the database
25-
if($submitted_token == $session->get('csrf_token')) {
26-
// Token is the same
27-
return true;
21+
// Check if a token was submitted
22+
if($submitted_token) {
23+
// Token was submitted
24+
// Bring in the session variable
25+
global $session;
26+
27+
// Check if the submitted token matches the one in the database
28+
if($submitted_token == $session->get('csrf_token')) {
29+
// Token is the same
30+
return true;
31+
} else {
32+
// Token is not the same
33+
return false;
34+
}
2835
} else {
29-
// Token is not the same
36+
// Token wasn't submitted
3037
return false;
3138
}
3239
}

0 commit comments

Comments
 (0)