add unsibscribe newsletter
This commit is contained in:
@@ -15,6 +15,8 @@ use yii\filters\AccessControl;
|
||||
use common\models\User;
|
||||
use common\components\Helper;
|
||||
use common\models\Log;
|
||||
use common\models\Customer;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
@@ -176,6 +178,26 @@ class SiteController extends Controller
|
||||
{
|
||||
return $this->render('about');
|
||||
}
|
||||
|
||||
public function actionNewsletterUnsubscribe($id,$token)
|
||||
{
|
||||
|
||||
$customer = Customer::find()
|
||||
->andWhere(['id_customer' => $id ])
|
||||
->andWhere(['newsletter_token' => $token])
|
||||
->one();
|
||||
|
||||
|
||||
if ( !isset($customer)){
|
||||
throw new NotFoundHttpException("Az oldal nem található");
|
||||
}
|
||||
|
||||
$customer->newsletter = 0;
|
||||
$customer->newsletter_token = Yii::$app->security->generateRandomString() . '_' . time();
|
||||
$customer->save();
|
||||
|
||||
return $this->render("unsubscribe");
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs user up.
|
||||
|
||||
Reference in New Issue
Block a user