Skip to content

Commit

Permalink
fix(CrsfTokenController): rename checkTockenThenRemove to checkTocken
Browse files Browse the repository at this point in the history
  • Loading branch information
J9rem committed Feb 14, 2022
1 parent 33d28eb commit 3d280dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions handlers/page/deletepage.php
Expand Up @@ -70,7 +70,7 @@
$msg .= "</form></span>\n";
} else {
try {
$csrfTokenController->checkTockenThenRemove("handler\deletepage\\$tag", 'POST', 'crsf-token');
$csrfTokenController->checkTocken("handler\deletepage\\$tag", 'POST', 'crsf-token');

$this->DeleteOrphanedPage($tag);
$this->LogAdministrativeAction($this->GetUserName(), "Suppression de la page ->\"\"" . $tag . "\"\"");
Expand All @@ -93,7 +93,7 @@
&& ($_GET['confirme'] === 'oui')) {
// a trouble occured, invald token ?
try {
$csrfTokenController->checkTockenThenRemove("handler\deletepage\\{$this->tag}", 'POST', 'crsf-token');
$csrfTokenController->checkTocken("handler\deletepage\\{$this->tag}", 'POST', 'crsf-token');
} catch (TokenNotFoundException $th) {
$msg .= $this->render("@templates/alert-message.twig", [
'type' => 'danger',
Expand Down
6 changes: 4 additions & 2 deletions includes/controllers/CsrfTokenController.php
Expand Up @@ -20,14 +20,16 @@ public function __construct(

/**
* check if token is present and valid in input
* throw TokenNotFoundException or Exception
*
* @param string $name
* @param string $inputType "GET" or "POST"
* @param string $inputKey key in the input to use
* @return bool
*
* @throws TokenNotFoundException
* @throws Exception
*/
public function checkTockenThenRemove(string $name, string $inputType, string $inputKey): bool
public function checkTocken(string $name, string $inputType, string $inputKey): bool
{
if (empty($name)) {
throw new Exception("parameter `\$name` should not be empty !");
Expand Down
6 changes: 3 additions & 3 deletions tools/login/actions/usersettings.php
Expand Up @@ -54,7 +54,7 @@
} elseif ($adminIsActing || $userLoggedIn) { // Admin or user wants to manage the user
if (substr($action, 0, 6) == 'update') { // Whoever it is tries to update the user
try {
$csrfTokenController->checkTockenThenRemove('login\action\usersettings\updateuser', 'POST', 'crsf-token');
$csrfTokenController->checkTocken('login\action\usersettings\updateuser', 'POST', 'crsf-token');

$OK = $this->user->setByAssociativeArray(array(
'email' => isset($_POST['email']) ? $_POST['email'] : '',
Expand Down Expand Up @@ -88,7 +88,7 @@

if ($action == 'deleteByAdmin') { // Admin trying to delete user
try {
$csrfTokenController->checkTockenThenRemove('login\action\usersettings\deleteByAdmin', 'POST', 'crsf-token');
$csrfTokenController->checkTocken('login\action\usersettings\deleteByAdmin', 'POST', 'crsf-token');

$this->user->delete();
// forward
Expand All @@ -106,7 +106,7 @@
} else { // user properly typed his old password in
// check token
try {
$csrfTokenController->checkTockenThenRemove('login\action\usersettings\changepass', 'POST', 'crsf-token');
$csrfTokenController->checkTocken('login\action\usersettings\changepass', 'POST', 'crsf-token');

$password = $_POST['password'];
if ($this->user->updatePassword($password)) {
Expand Down

0 comments on commit 3d280dc

Please sign in to comment.