Inline generateToken for clarity

The only thing Security::generateToken was providing was a default value
 for the $action, which created a pattern of using the same $action
 everywhere, which may not be the best way to go.

 Since it was essentially a wrapper for WP's built-in nonce functions,
 it seemed clearer to use those functions directly to be more explicit
 about how we're handling tokens.

[MAILPOET-2030]
This commit is contained in:
John Oleksowicz
2022-03-25 12:01:48 -05:00
committed by Veljko V
parent ed87d1cace
commit fc1f3e6dc2
6 changed files with 11 additions and 20 deletions

View File

@@ -14,7 +14,6 @@ use MailPoet\Models\Subscriber as SubscriberModel;
use MailPoet\Settings\SettingsController;
use MailPoet\Settings\SettingsRepository;
use MailPoet\Subscription\Form;
use MailPoet\Util\Security;
use MailPoet\Util\Url as UrlHelper;
use MailPoet\WP\Functions as WPFunctions;
use MailPoetVendor\Idiorm\ORM;
@@ -62,7 +61,7 @@ class FormTest extends \MailPoetTest {
'form_id' => $this->form->getId(),
$obfuscatedEmail => $this->testEmail,
],
'token' => Security::generateToken(),
'token' => WPFunctions::get()->wpCreateNonce('mailpoet_token'),
'api_version' => 'v1',
'endpoint' => 'subscribers',
'mailpoet_method' => 'subscribe',