Skip to content

Commit

Permalink
Merge pull request #14 from luyadev/fx-crypt-exception
Browse files Browse the repository at this point in the history
fix decrypt exception
  • Loading branch information
nadar authored Jan 19, 2021
2 parents c9c018a + ec2a788 commit 8ba8947
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 1.6.3 (19. January 2021)

+ [#14](https://github.com/luyadev/luya-mailjet/pull/14) Fix json decode exception when the parameter is violated in the subscribe form widget.

## 1.6.2 (30. December 2020)

+ [#13](https://github.com/luyadev/luya-mailjet/pull/13) Fix issue when sending emails with enabled template error reporting
Expand Down
16 changes: 9 additions & 7 deletions src/widgets/SubscribeFormWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function init()
}

$crypt = base64_encode(Yii::$app->security->encryptByPassword(Json::encode($this->getModel()->attributes), $this->hashSecret));
$url = Url::appendQuery(['w' => self::getId(), 'subscribe' => $crypt], true);
$url = Url::appendQuery(['w' => $this->getId(), 'subscribe' => $crypt], true);

if ($this->sendConfirmMail($url, $this->model->attributes)) {
Yii::$app->session->setFlash(self::MAIL_SENT_SUCCESS);
Expand Down Expand Up @@ -211,13 +211,15 @@ public function processConfirmLink()
$widgetId = Yii::$app->request->get('w');
$subscribe = Yii::$app->request->get('subscribe');

if ($widgetId == self::getId() && !empty($subscribe)) {
if ($widgetId == $this->getId() && !empty($subscribe)) {
$data = Yii::$app->security->decryptByPassword(base64_decode($subscribe), $this->hashSecret);
$attributes = Json::decode($data);
$this->getModel()->attributes = $attributes;
if ($this->getModel()->validate()) {
if ($this->addToList($this->getModelEmail(), $this->model->attributes)) {
Yii::$app->session->setFlash(self::MAIL_SUBSCRIBE_SUCCESS);
if ($data) {
$attributes = Json::decode($data);
$this->getModel()->attributes = $attributes;
if ($this->getModel()->validate()) {
if ($this->addToList($this->getModelEmail(), $this->model->attributes)) {
Yii::$app->session->setFlash(self::MAIL_SUBSCRIBE_SUCCESS);
}
}
}
}
Expand Down

0 comments on commit 8ba8947

Please sign in to comment.