diff --git a/lib/Models/Subscriber.php b/lib/Models/Subscriber.php index d927ecc862..203899345b 100644 --- a/lib/Models/Subscriber.php +++ b/lib/Models/Subscriber.php @@ -38,7 +38,9 @@ class Subscriber extends Model { const STATUS_BOUNCED = 'bounced'; const STATUS_INACTIVE = 'inactive'; + const DEPRECATED_LINK_TOKEN_LENGTH = 6; const LINK_TOKEN_LENGTH = 32; + /** @var string|bool */ public $token; @@ -121,7 +123,10 @@ class Subscriber extends Model { return self::where('wp_user_id', $wp_user->ID)->findOne(); } - static function generateToken($email = null, $length = 32) { + /** + * @deprecated Only for backward compatibility for old tokens + */ + static function generateToken($email = null, $length = self::DEPRECATED_LINK_TOKEN_LENGTH) { if ($email !== null) { $auth_key = ''; if (defined('AUTH_KEY')) { diff --git a/tests/integration/Models/SubscriberTest.php b/tests/integration/Models/SubscriberTest.php index 8608af7b63..98005c5b0a 100644 --- a/tests/integration/Models/SubscriberTest.php +++ b/tests/integration/Models/SubscriberTest.php @@ -674,7 +674,7 @@ class SubscriberTest extends \MailPoetTest { function testItGeneratesSubscriberToken() { $token = Subscriber::generateToken($this->test_data['email']); - expect(strlen($token))->equals(32); + expect(strlen($token))->equals(6); } function testItVerifiesSubscriberToken() {