Merge branch 'master' into static-code-analyzer

This commit is contained in:
Lorenzo Milesi
2022-08-11 09:50:37 +02:00
committed by GitHub
77 changed files with 2260 additions and 411 deletions

View File

@ -0,0 +1,68 @@
<?php
/*
* This file is part of the 2amigos/yii2-usuario project.
*
* (c) 2amigOS! <http://2amigos.us/>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
use Da\User\Widget\SessionStatusWidget;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use Da\User\Model\SessionHistory;
use Da\User\Search\SessionHistorySearch;
use yii\web\View;
use yii\data\ActiveDataProvider;
/**
* @var $this View
* @var $searchModel SessionHistorySearch
* @var $dataProvider ActiveDataProvider
*/
?>
<?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?>
<div class="row">
<div class="col-xs-12">
<?= Html::a(
Yii::t('usuario', 'Terminate all sessions'),
['/user/admin/terminate-sessions', 'id' => $user->id],
[
'class' => 'btn btn-danger btn-xs pull-right',
'data-method' => 'post'
]
) ?>
</div>
</div>
<hr>
<?php Pjax::begin(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'user_agent',
'ip',
[
'contentOptions' => [
'class' => 'text-nowrap',
],
'label' => Yii::t('usuario', 'Status'),
'value' => function (SessionHistory $model) {
return SessionStatusWidget::widget(['model' => $model]);
},
],
[
'attribute' => 'updated_at',
'format' => 'datetime'
],
],
]); ?>
<?php Pjax::end(); ?>
<?php $this->endContent() ?>

10
src/User/resources/views/admin/update.php Normal file → Executable file
View File

@ -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');
?>
<div class="clearfix"></div>
<?= $this->render(
'/shared/_alert',
[
'module' => Yii::$app->getModule('user'),
'module' => $module,
]
) ?>
@ -67,6 +70,11 @@ $this->params['breadcrumbs'][] = $this->title;
'label' => Yii::t('usuario', 'Assignments'),
'url' => ['/user/admin/assignments', 'id' => $user->id],
],
[
'label' => Yii::t('usuario', 'Session history'),
'url' => ['/user/admin/session-history', 'id' => $user->id],
'visible' => $module->enableSessionHistory,
],
'<hr>',
[
'label' => Yii::t('usuario', 'Confirm'),

View File

@ -30,5 +30,5 @@ use yii\helpers\Html;
<?= Yii::t('usuario', 'If you cannot click the link, please try pasting the text into your browser') ?>.
</p>
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.6; font-weight: normal; margin: 0 0 10px; padding: 0;">
<?= Yii::t('usuario', 'If you did not make this request you can ignore this email') ?>.
<?= Yii::t('usuario', 'You received this email because someone, possibly you or someone on your behalf, have created an account at {app_name}', ['app_name' => Yii::$app->name]) ?>.
</p>

View File

@ -22,4 +22,4 @@
<?= Yii::t('usuario', 'If you cannot click the link, please try pasting the text into your browser') ?>.
<?= Yii::t('usuario', 'If you did not make this request you can ignore this email') ?>.
<?= Yii::t('usuario', 'You received this email because someone, possibly you or someone on your behalf, have created an account at {app_name}', ['app_name' => Yii::$app->name]) ?>.

View File

@ -30,4 +30,4 @@
<?= Yii::t('usuario', 'If you cannot click the link, please try pasting the text into your browser') ?>.
<?php endif ?>
<?= Yii::t('usuario', 'If you did not make this request you can ignore this email') ?>.
<?= Yii::t('usuario', 'You received this email because someone, possibly you or someone on your behalf, have created an account at {app_name}', ['app_name' => Yii::$app->name]) ?>.

View File

@ -10,6 +10,7 @@
*/
use yii\helpers\Html;
use yii\helpers\Url;
/**
* @var \Da\User\Module $module
@ -28,6 +29,9 @@ use yii\helpers\Html;
<?php if ($showPassword || $module->generatePasswords): ?>
<?= Yii::t('usuario', 'We have generated a password for you') ?>: <strong><?= $user->password ?></strong>
<?php endif ?>
<?php if ($module->allowPasswordRecovery): ?>
<?= Yii::t('usuario', 'If you haven\'t received a password, you can reset it at') ?>: <strong><?= Html::a(Html::encode(Url::to(['/user/forgot'], true)), Url::to(['/user/forgot'], true)) ?></strong>
<?php endif ?>
</p>
@ -44,5 +48,5 @@ use yii\helpers\Html;
<?php endif ?>
<p style="font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.6; font-weight: normal; margin: 0 0 10px; padding: 0;">
<?= Yii::t('usuario', 'If you did not make this request you can ignore this email') ?>.
<?= Yii::t('usuario', 'You received this email because someone, possibly you or someone on your behalf, have created an account at {app_name}', ['app_name' => Yii::$app->name]) ?>.
</p>

10
src/User/resources/views/settings/_menu.php Normal file → Executable file
View File

@ -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;
@ -41,6 +44,11 @@ $networksVisible = count(Yii::$app->authClientCollection->clients) > 0;
'items' => [
['label' => Yii::t('usuario', 'Profile'), 'url' => ['/user/settings/profile']],
['label' => Yii::t('usuario', 'Account'), 'url' => ['/user/settings/account']],
[
'label' => Yii::t('usuario', 'Session history'),
'url' => ['/user/settings/session-history'],
'visible' => $module->enableSessionHistory,
],
['label' => Yii::t('usuario', 'Privacy'),
'url' => ['/user/settings/privacy'],
'visible' => $module->enableGdprCompliance

View File

@ -0,0 +1,79 @@
<?php
/*
* This file is part of the 2amigos/yii2-usuario project.
*
* (c) 2amigOS! <http://2amigos.us/>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use Da\User\Model\SessionHistory;
use Da\User\Search\SessionHistorySearch;
use yii\web\View;
use yii\data\ActiveDataProvider;
use Da\User\Widget\SessionStatusWidget;
/**
* @var $this View
* @var $searchModel SessionHistorySearch
* @var $dataProvider ActiveDataProvider
*/
$this->title = Yii::t('usuario', 'Session history');
$this->params['breadcrumbs'][] = $this->title;
?>
<?= $this->render('/shared/_alert', ['module' => Yii::$app->getModule('user')]) ?>
<div class="row">
<div class="col-md-3">
<?= $this->render('/settings/_menu') ?>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<?= Html::encode($this->title) ?>
<?= Html::a(
Yii::t('usuario', 'Terminate all sessions'),
['/user/settings/terminate-sessions'],
[
'class' => 'btn btn-danger btn-xs pull-right',
'data-method' => 'post'
]
) ?>
</div>
<div class="panel-body">
<?php Pjax::begin(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'user_agent',
'ip',
[
'contentOptions' => [
'class' => 'text-nowrap',
],
'label' => Yii::t('usuario', 'Status'),
'value' => function (SessionHistory $model) {
return SessionStatusWidget::widget(['model' => $model]);
},
],
[
'attribute' => 'updated_at',
'format' => 'datetime'
],
],
]); ?>
<?php Pjax::end(); ?>
</div>
</div>
</div>
</div>

View File

@ -35,9 +35,9 @@ use yii\widgets\ActiveForm;
]
) ?>
<?= $form->field($model, 'login')->textInput(['placeholder' => 'Login']) ?>
<?= $form->field($model, 'login')->textInput(['placeholder' => Yii::t('usuario', 'Login')]) ?>
<?= $form->field($model, 'password')->passwordInput(['placeholder' => 'Password']) ?>
<?= $form->field($model, 'password')->passwordInput(['placeholder' => Yii::t('usuario', 'Password')]) ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>