re #224 add option to require consent

This commit is contained in:
tonydspaniard
2019-08-21 11:13:48 +02:00
parent 07a7a7bda7
commit 5b071dae88
37 changed files with 406 additions and 106 deletions

View File

@ -2,10 +2,29 @@
namespace app\controllers;
use Da\User\Filter\AccessRuleFilter;
use yii\filters\AccessControl;
use yii\web\Controller;
class SiteController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'ruleConfig' => [
'class' => AccessRuleFilter::className(),
],
'rules' => [
[
'allow' => true,
],
],
],
];
}
public function actionIndex()
{
return $this->render('index');

View File

@ -14,6 +14,7 @@ return [
'created_at' => $time,
'updated_at' => $time,
'confirmed_at' => $time,
'gdpr_consent' => false,
],
'unconfirmed' => [
'id' => 2,

View File

@ -142,10 +142,10 @@ class GdprCest
$I->see('Export my data', 'h3');
$I->see('Delete my account', 'h3');
$I->amOnRoute('/user/settings/gdpr-delete');
$I->fillField('#gdprdeleteform-password','wrongpassword');
$I->fillField('#gdprdeleteform-password', 'wrongpassword');
$I->click('Delete');
$I->see('Invalid password');
$I->fillField('#gdprdeleteform-password','qwerty');
$I->fillField('#gdprdeleteform-password', 'qwerty');
$I->click('Delete');
$I->see('Login');
}
@ -163,5 +163,22 @@ class GdprCest
$I->amLoggedInAs(1);
$I->amOnRoute('/user/settings/privacy');
$I->seeResponseCodeIs(404);
$I->amOnRoute('/user/settings/privacy');
$I->see('Not Found');
}
public function testForcedConsentRequirement(FunctionalTester $I)
{
$this->_prepareModule(false,false);
/** @var Module $module */
$module = Yii::$app->getModule('user');
$module->gdprRequireConsentToAll = true;
$I->amGoingTo('Try to access a page without giving data processing consent');
$I->amLoggedInAs(1);
$I->amOnRoute('/site/index');
$I->seeElement('.give-consent-panel');
$I->checkOption('#dynamicmodel-gdpr_consent');
$I->click('Submit');
$I->see('Profile settings');
}
}