fixing bugs
This commit is contained in:
@ -4,7 +4,7 @@ namespace Da\User\AuthClient;
|
|||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
|
||||||
|
|
||||||
class Twitter extends \dektrium\user\clients\Twitter implements AuthClientInterface
|
class Twitter extends \yii\authclient\clients\Twitter implements AuthClientInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
@ -20,6 +20,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
*/
|
*/
|
||||||
public function bootstrap($app)
|
public function bootstrap($app)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($app->hasModule('user') && $app->getModule('user') instanceof Module) {
|
if ($app->hasModule('user') && $app->getModule('user') instanceof Module) {
|
||||||
$map = $this->buildClassMap($app->getModule('user')->classMap);
|
$map = $this->buildClassMap($app->getModule('user')->classMap);
|
||||||
$this->initContainer($map);
|
$this->initContainer($map);
|
||||||
@ -27,6 +28,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$this->initMailServiceConfiguration($app, $app->getModule('user'));
|
$this->initMailServiceConfiguration($app, $app->getModule('user'));
|
||||||
|
|
||||||
if ($app instanceof WebApplication) {
|
if ($app instanceof WebApplication) {
|
||||||
|
$this->initControllerNamespace($app);
|
||||||
$this->initUrlRoutes($app);
|
$this->initUrlRoutes($app);
|
||||||
$this->initAuthCollection($app);
|
$this->initAuthCollection($app);
|
||||||
} else {
|
} else {
|
||||||
@ -44,6 +46,8 @@ class Bootstrap implements BootstrapInterface
|
|||||||
protected function initContainer($map)
|
protected function initContainer($map)
|
||||||
{
|
{
|
||||||
$di = Yii::$container;
|
$di = Yii::$container;
|
||||||
|
try{
|
||||||
|
|
||||||
|
|
||||||
// events
|
// events
|
||||||
$di->set(Event\FormEvent::class);
|
$di->set(Event\FormEvent::class);
|
||||||
@ -65,9 +69,6 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$di->set(Helper\GravatarHelper::class);
|
$di->set(Helper\GravatarHelper::class);
|
||||||
$di->set(Helper\SecurityHelper::class);
|
$di->set(Helper\SecurityHelper::class);
|
||||||
|
|
||||||
// search class
|
|
||||||
$di->set(Search\UserSearch::class, [$di->get(Query\UserQuery::class)]);
|
|
||||||
|
|
||||||
// services
|
// services
|
||||||
$di->set(Service\AccountConfirmationService::class);
|
$di->set(Service\AccountConfirmationService::class);
|
||||||
$di->set(Service\EmailChangeService::class);
|
$di->set(Service\EmailChangeService::class);
|
||||||
@ -105,6 +106,9 @@ class Bootstrap implements BootstrapInterface
|
|||||||
}
|
}
|
||||||
$di->setSingleton(ClassMapHelper::class, ClassMapHelper::class, [$modelClassMap]);
|
$di->setSingleton(ClassMapHelper::class, ClassMapHelper::class, [$modelClassMap]);
|
||||||
|
|
||||||
|
// search class
|
||||||
|
$di->set(Search\UserSearch::class, [$di->get(Query\UserQuery::class)]);
|
||||||
|
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
// override Yii
|
// override Yii
|
||||||
$di->set(
|
$di->set(
|
||||||
@ -116,6 +120,9 @@ class Bootstrap implements BootstrapInterface
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}catch(Exception $e) {
|
||||||
|
die($e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,6 +205,16 @@ class Bootstrap implements BootstrapInterface
|
|||||||
$app->getModule('user')->controllerNamespace = 'Da\User\Command';
|
$app->getModule('user')->controllerNamespace = 'Da\User\Command';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers controllers
|
||||||
|
*
|
||||||
|
* @param WebApplication $app
|
||||||
|
*/
|
||||||
|
protected function initControllerNamespace(WebApplication $app)
|
||||||
|
{
|
||||||
|
$app->getModule('user')->controllerNamespace = 'Da\User\Controller';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds class map according to user configuration
|
* Builds class map according to user configuration
|
||||||
*
|
*
|
||||||
|
|||||||
45
lib/User/Widget/AssignmentsWidget.php
Normal file
45
lib/User/Widget/AssignmentsWidget.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Da\User\Widget;
|
||||||
|
|
||||||
|
use dektrium\rbac\components\DbManager;
|
||||||
|
use dektrium\rbac\models\Assignment;
|
||||||
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\base\Widget;
|
||||||
|
|
||||||
|
class AssignmentsWidget extends Widget
|
||||||
|
{
|
||||||
|
/** @var integer ID of the user to whom auth items will be assigned. */
|
||||||
|
public $userId;
|
||||||
|
|
||||||
|
/** @var DbManager */
|
||||||
|
protected $manager;
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
$this->manager = Yii::$app->authManager;
|
||||||
|
if ($this->userId === null) {
|
||||||
|
throw new InvalidConfigException('You should set ' . __CLASS__ . '::$userId');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$model = Yii::createObject([
|
||||||
|
'class' => Assignment::className(),
|
||||||
|
'user_id' => $this->userId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($model->load(\Yii::$app->request->post())) {
|
||||||
|
$model->updateAssignments();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('form', [
|
||||||
|
'model' => $model,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
lib/User/Widget/form.php
Normal file
53
lib/User/Widget/form.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Dektrium project
|
||||||
|
*
|
||||||
|
* (c) Dektrium project <http://github.com/dektrium>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use dektrium\rbac\models\Assignment;
|
||||||
|
use kartik\select2\Select2;
|
||||||
|
use yii\bootstrap\Alert;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $model Assignment
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if ($model->updated): ?>
|
||||||
|
|
||||||
|
<?= Alert::widget([
|
||||||
|
'options' => [
|
||||||
|
'class' => 'alert-success'
|
||||||
|
],
|
||||||
|
'body' => Yii::t('rbac', 'Assignments have been updated'),
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'enableClientValidation' => false,
|
||||||
|
'enableAjaxValidation' => false,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<?= Html::activeHiddenInput($model, 'user_id') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'items')->widget(Select2::className(), [
|
||||||
|
'data' => $model->getAvailableItems(),
|
||||||
|
'options' => [
|
||||||
|
'id' => 'items',
|
||||||
|
'multiple' => true
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<?= Html::submitButton(Yii::t('rbac', 'Update assignments'), ['class' => 'btn btn-success btn-block']) ?>
|
||||||
|
|
||||||
|
<?php ActiveForm::end() ?>
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use dektrium\rbac\widgets\Assignments;
|
use AssignmentsWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var yii\web\View $this
|
* @var yii\web\View $this
|
||||||
|
|||||||
@ -17,13 +17,11 @@ use yii\bootstrap\Nav;
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => Yii::t('user', 'Roles'),
|
'label' => Yii::t('user', 'Roles'),
|
||||||
'url' => ['/rbac/role/index'],
|
'url' => ['/rbac/role/index']
|
||||||
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => Yii::t('user', 'Permissions'),
|
'label' => Yii::t('user', 'Permissions'),
|
||||||
'url' => ['/rbac/permission/index'],
|
'url' => ['/rbac/permission/index']
|
||||||
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => Yii::t('user', 'Create'),
|
'label' => Yii::t('user', 'Create'),
|
||||||
@ -34,13 +32,11 @@ use yii\bootstrap\Nav;
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => Yii::t('user', 'New role'),
|
'label' => Yii::t('user', 'New role'),
|
||||||
'url' => ['/rbac/role/create'],
|
'url' => ['/rbac/role/create']
|
||||||
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'label' => Yii::t('user', 'New permission'),
|
'label' => Yii::t('user', 'New permission'),
|
||||||
'url' => ['/rbac/permission/create'],
|
'url' => ['/rbac/permission/create']
|
||||||
'visible' => isset(Yii::$app->extensions['dektrium/yii2-rbac']),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use dektrium\user\widgets\Connect;
|
use Da\User\Widget\ConnectWidget;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<?= Html::a(Yii::t('user', 'Don\'t have an account? Sign up!'), ['/user/registration/register']) ?>
|
<?= Html::a(Yii::t('user', 'Don\'t have an account? Sign up!'), ['/user/registration/register']) ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?= Connect::widget(
|
<?= ConnectWidget::widget(
|
||||||
[
|
[
|
||||||
'baseAuthUrl' => ['/user/security/auth'],
|
'baseAuthUrl' => ['/user/security/auth'],
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,17 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Dektrium project.
|
|
||||||
*
|
|
||||||
* (c) Dektrium project <http://github.com/dektrium>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE.md
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var yii\web\View $this
|
* @var yii\web\View $this
|
||||||
* @var dektrium\user\Module $module
|
* @var \Da\User\Module $module
|
||||||
|
* @var string $title
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
|||||||
Reference in New Issue
Block a user