added Subscriber::generateToken()
This commit is contained in:
@ -85,7 +85,6 @@ class Subscriber extends Model {
|
||||
return $this->getSubscriptionUrl($post, 'unsubscribe');
|
||||
}
|
||||
|
||||
|
||||
private function getSubscriptionUrl($post = null, $action = null) {
|
||||
if($post === null || $action === null) return;
|
||||
|
||||
@ -93,7 +92,7 @@ class Subscriber extends Model {
|
||||
|
||||
$params = array(
|
||||
'mailpoet_action='.$action,
|
||||
'mailpoet_token='.md5(AUTH_KEY.$this->email),
|
||||
'mailpoet_token='.self::generateToken($this->email),
|
||||
'mailpoet_email='.$this->email
|
||||
);
|
||||
// add parameters
|
||||
@ -176,6 +175,13 @@ class Subscriber extends Model {
|
||||
return false;
|
||||
}
|
||||
|
||||
static function generateToken($email = null) {
|
||||
if($email !== null) {
|
||||
return md5(AUTH_KEY.$email);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static function subscribe($subscriber_data = array(), $segment_ids = array()) {
|
||||
if(empty($subscriber_data) or empty($segment_ids)) {
|
||||
return false;
|
||||
|
@ -239,7 +239,7 @@ class Pages {
|
||||
)
|
||||
);
|
||||
|
||||
$content = \MailPoet\Form\Renderer::renderBlocks($form);
|
||||
return \MailPoet\Form\Renderer::renderBlocks($form);
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ class Pages {
|
||||
? $_GET['mailpoet_email']
|
||||
: null;
|
||||
|
||||
if(md5(AUTH_KEY.$email) === $token) {
|
||||
if(Subscriber::generateToken($email) === $token) {
|
||||
$subscriber = Subscriber::findOne($email);
|
||||
if($subscriber !== false) {
|
||||
return $subscriber;
|
||||
|
Reference in New Issue
Block a user