From e41681bf70ed7f7f849a66772537bbe1b6df0f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5nis=20Ormisson?= Date: Mon, 10 Sep 2018 18:46:26 +0300 Subject: [PATCH 1/6] DEV: add some phpDoc references --- src/User/Filter/PasswordAgeEnforceFilter.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/User/Filter/PasswordAgeEnforceFilter.php b/src/User/Filter/PasswordAgeEnforceFilter.php index 2da75dc..9f92746 100644 --- a/src/User/Filter/PasswordAgeEnforceFilter.php +++ b/src/User/Filter/PasswordAgeEnforceFilter.php @@ -12,6 +12,8 @@ namespace Da\User\Filter; +use Da\User\Model\User; +use Da\User\Module; use Yii; use yii\base\ActionFilter; @@ -19,7 +21,9 @@ class PasswordAgeEnforceFilter extends ActionFilter { public function beforeAction($action) { - $maxPasswordAge = Yii::$app->getModule('user')->maxPasswordAge; + /** @var Module $module */ + $module = Yii::$app->getModule('user'); + $maxPasswordAge = $module->maxPasswordAge; // If feature is not set do nothing (or raise a configuration error?) if (is_null($maxPasswordAge)) { return parent::beforeAction($action); @@ -28,7 +32,9 @@ class PasswordAgeEnforceFilter extends ActionFilter // Not our business return parent::beforeAction($action); } - if (Yii::$app->user->identity->password_age >= $maxPasswordAge) { + /** @var User $identity */ + $identity = Yii::$app->user->identity; + if ($identity->password_age >= $maxPasswordAge) { // Force password change Yii::$app->getSession()->setFlash('warning', Yii::t('usuario', 'Your password has expired, you must change it now')); return Yii::$app->response->redirect(['/user/settings/account'])->send(); From e9bca868288de6819e6f86ac3636cc32668a81bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5nis=20Ormisson?= Date: Tue, 11 Sep 2018 22:58:21 +0300 Subject: [PATCH 2/6] DEV: replace deprecated ::className() with ::class (#232) --- src/User/Controller/AbstractAuthItemController.php | 4 ++-- src/User/Controller/ProfileController.php | 2 +- src/User/Controller/RecoveryController.php | 2 +- src/User/Controller/RegistrationController.php | 2 +- src/User/Controller/RuleController.php | 6 +++--- src/User/Controller/SecurityController.php | 6 +++--- src/User/Controller/SettingsController.php | 4 ++-- src/User/Model/User.php | 2 +- src/User/resources/views/permission/index.php | 2 +- src/User/resources/views/role/index.php | 2 +- src/User/resources/views/rule/index.php | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/User/Controller/AbstractAuthItemController.php b/src/User/Controller/AbstractAuthItemController.php index 65d0f3f..4b49465 100644 --- a/src/User/Controller/AbstractAuthItemController.php +++ b/src/User/Controller/AbstractAuthItemController.php @@ -51,9 +51,9 @@ abstract class AbstractAuthItemController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'ruleConfig' => [ - 'class' => AccessRuleFilter::className(), + 'class' => AccessRuleFilter::class, ], 'rules' => [ [ diff --git a/src/User/Controller/ProfileController.php b/src/User/Controller/ProfileController.php index 9852d7c..2e99fe1 100644 --- a/src/User/Controller/ProfileController.php +++ b/src/User/Controller/ProfileController.php @@ -43,7 +43,7 @@ class ProfileController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, diff --git a/src/User/Controller/RecoveryController.php b/src/User/Controller/RecoveryController.php index cd2f621..00e4ec7 100644 --- a/src/User/Controller/RecoveryController.php +++ b/src/User/Controller/RecoveryController.php @@ -60,7 +60,7 @@ class RecoveryController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, diff --git a/src/User/Controller/RegistrationController.php b/src/User/Controller/RegistrationController.php index 8c97bce..f321413 100644 --- a/src/User/Controller/RegistrationController.php +++ b/src/User/Controller/RegistrationController.php @@ -69,7 +69,7 @@ class RegistrationController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, diff --git a/src/User/Controller/RuleController.php b/src/User/Controller/RuleController.php index ccd6134..74626ca 100644 --- a/src/User/Controller/RuleController.php +++ b/src/User/Controller/RuleController.php @@ -36,15 +36,15 @@ class RuleController extends Controller { return [ 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'delete' => ['POST'], ], ], 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'ruleConfig' => [ - 'class' => AccessRuleFilter::className(), + 'class' => AccessRuleFilter::class, ], 'rules' => [ [ diff --git a/src/User/Controller/SecurityController.php b/src/User/Controller/SecurityController.php index 00c373e..403e406 100644 --- a/src/User/Controller/SecurityController.php +++ b/src/User/Controller/SecurityController.php @@ -61,7 +61,7 @@ class SecurityController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, @@ -76,7 +76,7 @@ class SecurityController extends Controller ], ], 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'logout' => ['post'], ], @@ -91,7 +91,7 @@ class SecurityController extends Controller { return [ 'auth' => [ - 'class' => AuthAction::className(), + 'class' => AuthAction::class, // if user is not logged in, will try to log him in, otherwise // will try to connect social account to user. 'successCallback' => Yii::$app->user->isGuest diff --git a/src/User/Controller/SettingsController.php b/src/User/Controller/SettingsController.php index 16fe6d8..3ada228 100644 --- a/src/User/Controller/SettingsController.php +++ b/src/User/Controller/SettingsController.php @@ -86,7 +86,7 @@ class SettingsController extends Controller { return [ 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'disconnect' => ['post'], 'delete' => ['post'], @@ -94,7 +94,7 @@ class SettingsController extends Controller ], ], 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, diff --git a/src/User/Model/User.php b/src/User/Model/User.php index d333453..c4fc048 100644 --- a/src/User/Model/User.php +++ b/src/User/Model/User.php @@ -161,7 +161,7 @@ class User extends ActiveRecord implements IdentityInterface public function behaviors() { $behaviors = [ - TimestampBehavior::className(), + TimestampBehavior::class, ]; if ($this->module->enableGDPRcompliance) { diff --git a/src/User/resources/views/permission/index.php b/src/User/resources/views/permission/index.php index a3f3958..18c61a6 100644 --- a/src/User/resources/views/permission/index.php +++ b/src/User/resources/views/permission/index.php @@ -53,7 +53,7 @@ $this->params['breadcrumbs'][] = $this->title; ], ], [ - 'class' => ActionColumn::className(), + 'class' => ActionColumn::class, 'template' => '{update} {delete}', 'urlCreator' => function ($action, $model) { return Url::to(['/user/permission/' . $action, 'name' => $model['name']]); diff --git a/src/User/resources/views/role/index.php b/src/User/resources/views/role/index.php index 0713f4c..e18b817 100644 --- a/src/User/resources/views/role/index.php +++ b/src/User/resources/views/role/index.php @@ -54,7 +54,7 @@ $this->params['breadcrumbs'][] = $this->title; ], ], [ - 'class' => ActionColumn::className(), + 'class' => ActionColumn::class, 'template' => '{update} {delete}', 'urlCreator' => function ($action, $model) { return Url::to(['/user/role/' . $action, 'name' => $model['name']]); diff --git a/src/User/resources/views/rule/index.php b/src/User/resources/views/rule/index.php index 9724ec8..7e5e15d 100644 --- a/src/User/resources/views/rule/index.php +++ b/src/User/resources/views/rule/index.php @@ -60,7 +60,7 @@ $this->params['breadcrumbs'][] = $this->title; ], ], [ - 'class' => ActionColumn::className(), + 'class' => ActionColumn::class, 'template' => '{update} {delete}', 'urlCreator' => function ($action, $model) { return Url::to(['/user/rule/' . $action, 'name' => $model['name']]); From 75b9cd87d5002db2428ce5f9e5a1bb65a0c26415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5nis=20Ormisson?= Date: Wed, 12 Sep 2018 09:13:31 +0300 Subject: [PATCH 3/6] =?UTF-8?q?DEV:=20replace=20deprecated=20InvalidParamE?= =?UTF-8?q?xception=20with=20InvalidArgumentExc=E2=80=A6=20(#235)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/User/Helper/ClassMapHelper.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68200ea..fab6c36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Fix #168: Fix spelling in russian language (EvgenyOrekhov) - Fix #195: UserCreateService: check if we're from web before setting flash message (maxxer) - Enh: Improvements to the admin responsive design (wautvda) + - Enh: Replace the deprecated InvalidParamException in ClassMapHelper (TonisOrmisson) ## 1.1.4 - February 19, 2018 - Enh: Check enableEmailConfirmation on registration (faenir) diff --git a/src/User/Helper/ClassMapHelper.php b/src/User/Helper/ClassMapHelper.php index 3ca99f8..d1043c6 100644 --- a/src/User/Helper/ClassMapHelper.php +++ b/src/User/Helper/ClassMapHelper.php @@ -11,7 +11,7 @@ namespace Da\User\Helper; -use yii\base\InvalidParamException; +use yii\base\InvalidArgumentException; class ClassMapHelper { @@ -39,7 +39,7 @@ class ClassMapHelper /** * @param $key * - * @throws InvalidParamException + * @throws \InvalidArgumentException * @return mixed * */ @@ -48,6 +48,6 @@ class ClassMapHelper if (array_key_exists($key, $this->map)) { return $this->map[$key]; } - throw new InvalidParamException('Unknown model map key: ' . $key); + throw new InvalidArgumentException('Unknown model map key: ' . $key); } } From bd691ec9bb42ce02b875a277e1d670297128457c Mon Sep 17 00:00:00 2001 From: bscheshirwork Date: Wed, 12 Sep 2018 18:03:25 +0300 Subject: [PATCH 4/6] Additional info on the migration guide from Dektrium tools --- .../migration-guide-from-dektrium-tools.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/installation/migration-guide-from-dektrium-tools.md b/docs/installation/migration-guide-from-dektrium-tools.md index 1f4a963..fc026b3 100644 --- a/docs/installation/migration-guide-from-dektrium-tools.md +++ b/docs/installation/migration-guide-from-dektrium-tools.md @@ -53,6 +53,18 @@ In `config/web.php` remove *module > rbac* configuration and change the *modules * If you had `modelMap` customization you have to replace them with `classMap`. * In your extended model replace the `BaseUser` inheritance from `dektrium\user\models\User` to `Da\User\Model\User` * If you had controller remapping replace the inheritance from `dektrium\user\controllers\XX` to `Da\User\Controller\XX` +* Some properties has been renamed: from `enableConfirmation` to `enableEmailConfirmation`; from `enableGeneratingPassword` to `generatePasswords` +* Restore Identity url rule has been renamed: from `/user/admin/switch` to `/user/admin/switch-identity` +* Restore Identity session checker has changes: from +```php +if (Yii::$app->session->has(\dektrium\user\controllers\AdminController::ORIGINAL_USER_SESSION_KEY)) +``` +to +```php +/** @var Da\User\Module $module */ +$module = Yii::$app->getModule('user'); +if(Yii::$app->session->has($module->switchIdentitySessionKey)) +``` ## Rbac migrations From bd4639e98e6777d037ee5f57acc39ffc000e04db Mon Sep 17 00:00:00 2001 From: bscheshirwork Date: Fri, 14 Sep 2018 11:51:05 +0300 Subject: [PATCH 5/6] Update GdprCest.php (#239) Remove bad 3x checks Just add check 404 code --- tests/functional/GdprCest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/functional/GdprCest.php b/tests/functional/GdprCest.php index 855c842..1ae2e91 100644 --- a/tests/functional/GdprCest.php +++ b/tests/functional/GdprCest.php @@ -162,9 +162,6 @@ class GdprCest $this->_prepareModule(false, false,false); $I->amLoggedInAs(1); $I->amOnRoute('/user/settings/privacy'); - $I->see('Not Found'); - $I->amOnRoute('/user/settings/privacy'); - $I->see('Not Found');$I->amOnRoute('/user/settings/privacy'); - $I->see('Not Found'); + $I->seeResponseCodeIs(404); } } From 26837b7fd94da6d131655f03e0f499cd06af1c16 Mon Sep 17 00:00:00 2001 From: bscheshirwork Date: Fri, 14 Sep 2018 11:51:31 +0300 Subject: [PATCH 6/6] Update available-actions.md (#240) Add info about confirmation email and privacy page --- docs/installation/available-actions.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/installation/available-actions.md b/docs/installation/available-actions.md index 05c2c89..5ba8d44 100644 --- a/docs/installation/available-actions.md +++ b/docs/installation/available-actions.md @@ -13,6 +13,9 @@ The following is the list of action provided by the module: - **/user/settings/profile** Displays profile settings form - **/user/settings/account** Displays account settings form (email, username, password) - **/user/settings/networks** Displays social network accounts settings page +- **/user/settings/confirm** Confirms a new email (requires *id* and *token* query params) +- **/user/settings/privacy**     Displays GDPR data page +- **/user/settings/gdprdelete**   Displays delete personal data page - **/user/profile/show** Displays user's profile (requires *id* query param) - **/user/admin/index** Displays user management interface - **/user/admin/create** Displays create user form