diff --git a/CHANGELOG.md b/CHANGELOG.md index c228557..302886e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Fix #195: UserCreateService: check if we're from web before setting flash message (maxxer) - Enh: Improvements to the admin responsive design (wautvda) - Enh: Add controller module class reference (TonisOrmisson) + - Enh: Replace the deprecated InvalidParamException in ClassMapHelper (TonisOrmisson) ## 1.1.4 - February 19, 2018 - Enh: Check enableEmailConfirmation on registration (faenir) 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 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 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 045d513..33c19ee 100644 --- a/src/User/Controller/RecoveryController.php +++ b/src/User/Controller/RecoveryController.php @@ -63,7 +63,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 20ee421..424d8b0 100644 --- a/src/User/Controller/RegistrationController.php +++ b/src/User/Controller/RegistrationController.php @@ -72,7 +72,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 5e1a36a..5412e5f 100644 --- a/src/User/Controller/SecurityController.php +++ b/src/User/Controller/SecurityController.php @@ -64,7 +64,7 @@ class SecurityController extends Controller { return [ 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, @@ -79,7 +79,7 @@ class SecurityController extends Controller ], ], 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'logout' => ['post'], ], @@ -94,7 +94,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 440d655..a4f891f 100644 --- a/src/User/Controller/SettingsController.php +++ b/src/User/Controller/SettingsController.php @@ -89,7 +89,7 @@ class SettingsController extends Controller { return [ 'verbs' => [ - 'class' => VerbFilter::className(), + 'class' => VerbFilter::class, 'actions' => [ 'disconnect' => ['post'], 'delete' => ['post'], @@ -97,7 +97,7 @@ class SettingsController extends Controller ], ], 'access' => [ - 'class' => AccessControl::className(), + 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 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(); 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); } } 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']]); 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); } }