From b7d2cf42ac4612a83d87c180211c3cd4c01c1c53 Mon Sep 17 00:00:00 2001 From: maranqz Date: Sat, 30 Nov 2019 17:52:24 +0300 Subject: [PATCH] Fix: 1. Documentation; 2. Actions access in AdminController and SettingController by enableSessionHistory; 3. Add "visible" menu parameter by enableSessionHistory; 4. Add blank line in end of file. --- docs/helpful-guides/how-to-use-session-history.md | 4 ++-- docs/installation/configuration-options.md | 2 +- src/User/Controller/AdminController.php | 5 +++++ src/User/Controller/SettingsController.php | 7 +++++-- .../Service/SessionHistory/DBTerminateSessionsService.php | 2 +- .../Service/SessionHistory/SessionHistoryDecorator.php | 2 +- .../Service/SessionHistory/TerminateSessionsService.php | 2 +- .../SessionHistory/TerminateSessionsServiceInterface.php | 2 +- .../SessionHistory/TerminateUserSessionsService.php | 2 +- src/User/resources/views/admin/_session-history.php | 2 +- src/User/resources/views/admin/update.php | 6 +++++- src/User/resources/views/settings/_menu.php | 8 ++++++-- src/User/resources/views/settings/session-history.php | 2 +- 13 files changed, 31 insertions(+), 15 deletions(-) diff --git a/docs/helpful-guides/how-to-use-session-history.md b/docs/helpful-guides/how-to-use-session-history.md index 508c49f..f392f8e 100755 --- a/docs/helpful-guides/how-to-use-session-history.md +++ b/docs/helpful-guides/how-to-use-session-history.md @@ -1,9 +1,9 @@ How to enable session history ============================ -Session history is list user sessions. +Session history list user sessions. -User can delete all session except current. +User can delete all sessions except current. Configure Module and Application -------------------------------- diff --git a/docs/installation/configuration-options.md b/docs/installation/configuration-options.md index 9332a6c..6fd032d 100755 --- a/docs/installation/configuration-options.md +++ b/docs/installation/configuration-options.md @@ -17,7 +17,7 @@ Number of expired storing records `session history`, values: How long store `session history` after expiring, values: - `false` Store all records without deleting -- `integer` Time for storing after expiring +- `integer` Time for storing after expiring in seconds #### enableTwoFactorAuthentication (type: `boolean`, default: `false`) diff --git a/src/User/Controller/AdminController.php b/src/User/Controller/AdminController.php index 7b8ebab..4458a8e 100755 --- a/src/User/Controller/AdminController.php +++ b/src/User/Controller/AdminController.php @@ -104,6 +104,11 @@ class AdminController extends Controller 'actions' => ['switch-identity'], 'roles' => ['@'], ], + [ + 'allow' => $this->getModule()->enableSessionHistory, + 'actions' => ['session-history', 'terminate-sessions'], + 'roles' => ['admin'], + ], [ 'allow' => true, 'roles' => ['admin'], diff --git a/src/User/Controller/SettingsController.php b/src/User/Controller/SettingsController.php index e40c30b..9cbbd91 100755 --- a/src/User/Controller/SettingsController.php +++ b/src/User/Controller/SettingsController.php @@ -115,8 +115,6 @@ class SettingsController extends Controller 'two-factor', 'two-factor-enable', 'two-factor-disable', - 'session-history', - 'terminate-sessions', ], 'roles' => ['@'], ], @@ -125,6 +123,11 @@ class SettingsController extends Controller 'actions' => ['confirm'], 'roles' => ['?', '@'], ], + [ + 'allow' => $this->getModule()->enableSessionHistory, + 'actions' => ['session-history', 'terminate-sessions'], + 'roles' => ['@'], + ], ], ], ]; diff --git a/src/User/Service/SessionHistory/DBTerminateSessionsService.php b/src/User/Service/SessionHistory/DBTerminateSessionsService.php index ad0021a..f494c5c 100755 --- a/src/User/Service/SessionHistory/DBTerminateSessionsService.php +++ b/src/User/Service/SessionHistory/DBTerminateSessionsService.php @@ -40,4 +40,4 @@ class DBTerminateSessionsService implements TerminateSessionsServiceInterface return true; } -} \ No newline at end of file +} diff --git a/src/User/Service/SessionHistory/SessionHistoryDecorator.php b/src/User/Service/SessionHistory/SessionHistoryDecorator.php index d337825..a1c0032 100755 --- a/src/User/Service/SessionHistory/SessionHistoryDecorator.php +++ b/src/User/Service/SessionHistory/SessionHistoryDecorator.php @@ -458,4 +458,4 @@ class SessionHistoryDecorator extends Session { return Yii::$app->getDb(); } -} \ No newline at end of file +} diff --git a/src/User/Service/SessionHistory/TerminateSessionsService.php b/src/User/Service/SessionHistory/TerminateSessionsService.php index d15f13d..ae4aaad 100755 --- a/src/User/Service/SessionHistory/TerminateSessionsService.php +++ b/src/User/Service/SessionHistory/TerminateSessionsService.php @@ -45,4 +45,4 @@ class TerminateSessionsService implements TerminateSessionsServiceInterface return true; } -} \ No newline at end of file +} diff --git a/src/User/Service/SessionHistory/TerminateSessionsServiceInterface.php b/src/User/Service/SessionHistory/TerminateSessionsServiceInterface.php index f12b112..35d4dfa 100755 --- a/src/User/Service/SessionHistory/TerminateSessionsServiceInterface.php +++ b/src/User/Service/SessionHistory/TerminateSessionsServiceInterface.php @@ -16,4 +16,4 @@ use Da\User\Contracts\ServiceInterface; interface TerminateSessionsServiceInterface extends ServiceInterface { -} \ No newline at end of file +} diff --git a/src/User/Service/SessionHistory/TerminateUserSessionsService.php b/src/User/Service/SessionHistory/TerminateUserSessionsService.php index 7a91a94..377130a 100755 --- a/src/User/Service/SessionHistory/TerminateUserSessionsService.php +++ b/src/User/Service/SessionHistory/TerminateUserSessionsService.php @@ -102,4 +102,4 @@ class TerminateUserSessionsService implements ServiceInterface { return $this->excludeCurrentSession && $this->userId === Yii::$app->user->id; } -} \ No newline at end of file +} diff --git a/src/User/resources/views/admin/_session-history.php b/src/User/resources/views/admin/_session-history.php index 8593e42..3e6c2cf 100755 --- a/src/User/resources/views/admin/_session-history.php +++ b/src/User/resources/views/admin/_session-history.php @@ -65,4 +65,4 @@ use yii\data\ActiveDataProvider; ]); ?> -endContent() ?> \ No newline at end of file +endContent() ?> diff --git a/src/User/resources/views/admin/update.php b/src/User/resources/views/admin/update.php index f884ce7..a90fd96 100755 --- a/src/User/resources/views/admin/update.php +++ b/src/User/resources/views/admin/update.php @@ -13,6 +13,7 @@ use Da\User\Model\User; use yii\bootstrap\Nav; use yii\helpers\Html; use yii\web\View; +use Da\User\Module as UserModule; /** * @var View $this @@ -24,12 +25,14 @@ $this->title = Yii::t('usuario', 'Update user account'); $this->params['breadcrumbs'][] = ['label' => Yii::t('usuario', 'Users'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; +/** @var UserModule $module */ +$module = Yii::$app->getModule('user'); ?>
render( '/shared/_alert', [ - 'module' => Yii::$app->getModule('user'), + 'module' => $module, ] ) ?> @@ -70,6 +73,7 @@ $this->params['breadcrumbs'][] = $this->title; [ 'label' => Yii::t('usuario', 'Session history'), 'url' => ['/user/admin/session-history', 'id' => $user->id], + 'visible' => $module->enableSessionHistory, ], '
', [ diff --git a/src/User/resources/views/settings/_menu.php b/src/User/resources/views/settings/_menu.php index 69c2270..bd3c2af 100755 --- a/src/User/resources/views/settings/_menu.php +++ b/src/User/resources/views/settings/_menu.php @@ -11,9 +11,12 @@ use yii\helpers\Html; use yii\widgets\Menu; +use Da\User\Module as UserModule; +use Da\User\Model\User; -/** @var \Da\User\Model\User $user */ +/** @var User $user */ $user = Yii::$app->user->identity; +/** @var UserModule $module */ $module = Yii::$app->getModule('user'); $networksVisible = count(Yii::$app->authClientCollection->clients) > 0; @@ -43,7 +46,8 @@ $networksVisible = count(Yii::$app->authClientCollection->clients) > 0; ['label' => Yii::t('usuario', 'Account'), 'url' => ['/user/settings/account']], [ 'label' => Yii::t('usuario', 'Session history'), - 'url' => ['/user/settings/session-history'] + 'url' => ['/user/settings/session-history'], + 'visible' => $module->enableSessionHistory, ], ['label' => Yii::t('usuario', 'Privacy'), 'url' => ['/user/settings/privacy'], diff --git a/src/User/resources/views/settings/session-history.php b/src/User/resources/views/settings/session-history.php index 0e00a77..467ea93 100755 --- a/src/User/resources/views/settings/session-history.php +++ b/src/User/resources/views/settings/session-history.php @@ -76,4 +76,4 @@ $this->params['breadcrumbs'][] = $this->title; - \ No newline at end of file +