fix formatting
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Filter\AccessRuleFilter;
|
||||
@ -23,10 +24,10 @@ abstract class AbstractAuthItemController extends Controller
|
||||
/**
|
||||
* AbstractAuthItemController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param AuthHelper $authHelper
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($id, Module $module, AuthHelper $authHelper, array $config = [])
|
||||
{
|
||||
@ -35,7 +36,7 @@ abstract class AbstractAuthItemController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -63,7 +64,7 @@ abstract class AbstractAuthItemController extends Controller
|
||||
'index',
|
||||
[
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $searchModel->search(Yii::$app->request->get())
|
||||
'dataProvider' => $searchModel->search(Yii::$app->request->get()),
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -82,7 +83,6 @@ abstract class AbstractAuthItemController extends Controller
|
||||
->setFlash('success', Yii::t('user', 'Authorization item successfully created.'));
|
||||
|
||||
return $this->redirect(['index']);
|
||||
|
||||
} else {
|
||||
Yii::$app->getSession()->setFlash('danger', Yii::t('user', 'Unable to create authorization item.'));
|
||||
}
|
||||
@ -92,7 +92,7 @@ abstract class AbstractAuthItemController extends Controller
|
||||
'create',
|
||||
[
|
||||
'model' => $model,
|
||||
'unassignedItems' => $this->authHelper->getUnassignedItems($model)
|
||||
'unassignedItems' => $this->authHelper->getUnassignedItems($model),
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -107,14 +107,12 @@ abstract class AbstractAuthItemController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, [$model])->validate();
|
||||
|
||||
if ($model->load(Yii::$app->request->post())) {
|
||||
|
||||
if ($this->make(AuthItemEditionService::class, [$model])->run()) {
|
||||
Yii::$app
|
||||
->getSession()
|
||||
->setFlash('success', Yii::t('user', 'Authorization item successfully updated.'));
|
||||
|
||||
return $this->redirect(['index']);
|
||||
|
||||
} else {
|
||||
Yii::$app->getSession()->setFlash('danger', Yii::t('user', 'Unable to update authorization item.'));
|
||||
}
|
||||
@ -124,7 +122,7 @@ abstract class AbstractAuthItemController extends Controller
|
||||
'update',
|
||||
[
|
||||
'model' => $model,
|
||||
'unassignedItems' => $this->authHelper->getUnassignedItems($model)
|
||||
'unassignedItems' => $this->authHelper->getUnassignedItems($model),
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -143,26 +141,25 @@ abstract class AbstractAuthItemController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* The fully qualified class name of the model
|
||||
* The fully qualified class name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getModelClass();
|
||||
|
||||
/**
|
||||
* The fully qualified class name of the search model
|
||||
* The fully qualified class name of the search model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getSearchModelClass();
|
||||
|
||||
/**
|
||||
* Returns the an auth item
|
||||
* Returns the an auth item.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return \yii\rbac\Role|\yii\rbac\Permission|\yii\rbac\Rule
|
||||
*/
|
||||
abstract protected function getItem($name);
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Event\UserEvent;
|
||||
@ -21,7 +22,6 @@ use yii\filters\VerbFilter;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
use ContainerTrait;
|
||||
@ -34,10 +34,10 @@ class AdminController extends Controller
|
||||
/**
|
||||
* AdminController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param UserQuery $userQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($id, Module $module, UserQuery $userQuery, array $config = [])
|
||||
{
|
||||
@ -60,7 +60,7 @@ class AdminController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -97,7 +97,7 @@ class AdminController extends Controller
|
||||
'index',
|
||||
[
|
||||
'dataProvider' => $dataProvider,
|
||||
'searchModel' => $searchModel
|
||||
'searchModel' => $searchModel,
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -113,13 +113,11 @@ class AdminController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, [$user])->validate();
|
||||
|
||||
if ($user->load(Yii::$app->request->post())) {
|
||||
|
||||
$this->trigger(UserEvent::EVENT_BEFORE_CREATE, $event);
|
||||
|
||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||
|
||||
if ($this->make(UserCreateService::class, [$user, $mailService])->run()) {
|
||||
|
||||
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created'));
|
||||
$this->trigger(UserEvent::EVENT_AFTER_CREATE, $event);
|
||||
|
||||
@ -181,7 +179,7 @@ class AdminController extends Controller
|
||||
'_profile',
|
||||
[
|
||||
'user' => $user,
|
||||
'profile' => $profile
|
||||
'profile' => $profile,
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -208,7 +206,7 @@ class AdminController extends Controller
|
||||
'_assignments',
|
||||
[
|
||||
'user' => $user,
|
||||
'params' => Yii::$app->request->post()
|
||||
'params' => Yii::$app->request->post(),
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -225,7 +223,6 @@ class AdminController extends Controller
|
||||
if ($this->make(UserConfirmationService::class, [$user])->run()) {
|
||||
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been confirmed'));
|
||||
$this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);
|
||||
|
||||
} else {
|
||||
Yii::$app->getSession()->setFlash('warning', Yii::t('user', 'Unable to confirm user. Please, try again.'));
|
||||
}
|
||||
@ -247,7 +244,6 @@ class AdminController extends Controller
|
||||
if ($user->delete()) {
|
||||
Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been deleted'));
|
||||
$this->trigger(ActiveRecord::EVENT_AFTER_DELETE, $event);
|
||||
|
||||
} else {
|
||||
Yii::$app->getSession()->setFlash(
|
||||
'warning',
|
||||
@ -279,4 +275,3 @@ class AdminController extends Controller
|
||||
return $this->redirect(Url::previous('actions-redirect'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Da\User\Controller;
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Model\Permission;
|
||||
use Da\User\Search\PermissionSearch;
|
||||
@ -9,7 +9,7 @@ use yii\web\NotFoundHttpException;
|
||||
class PermissionController extends AbstractAuthItemController
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getModelClass()
|
||||
{
|
||||
@ -17,7 +17,7 @@ class PermissionController extends AbstractAuthItemController
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getSearchModelClass()
|
||||
{
|
||||
@ -25,7 +25,7 @@ class PermissionController extends AbstractAuthItemController
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getItem($name)
|
||||
{
|
||||
@ -37,5 +37,4 @@ class PermissionController extends AbstractAuthItemController
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Query\ProfileQuery;
|
||||
@ -15,10 +16,10 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* ProfileController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param ProfileQuery $profileQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($id, Module $module, ProfileQuery $profileQuery, array $config = [])
|
||||
{
|
||||
@ -27,7 +28,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -38,12 +39,12 @@ class ProfileController extends Controller
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['index'],
|
||||
'roles' => ['@']
|
||||
'roles' => ['@'],
|
||||
],
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['show'],
|
||||
'roles' => ['?', '@']
|
||||
'roles' => ['?', '@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -70,5 +71,4 @@ class ProfileController extends Controller
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Event\FormEvent;
|
||||
@ -28,11 +29,11 @@ class RecoveryController extends Controller
|
||||
/**
|
||||
* RecoveryController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param UserQuery $userQuery
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param UserQuery $userQuery
|
||||
* @param TokenQuery $tokenQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($id, Module $module, UserQuery $userQuery, TokenQuery $tokenQuery, array $config = [])
|
||||
{
|
||||
@ -42,7 +43,7 @@ class RecoveryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -53,7 +54,7 @@ class RecoveryController extends Controller
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['request', 'reset'],
|
||||
'roles' => ['?']
|
||||
'roles' => ['?'],
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -64,11 +65,11 @@ class RecoveryController extends Controller
|
||||
* Displays / handles user password recovery request.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionRequest()
|
||||
{
|
||||
|
||||
if (!$this->module->allowPasswordRecovery) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
@ -81,13 +82,11 @@ class RecoveryController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, $form)->validate();
|
||||
|
||||
if ($form->load(Yii::$app->request->post())) {
|
||||
|
||||
$this->trigger(FormEvent::EVENT_BEFORE_REQUEST, $event);
|
||||
|
||||
$mailService = MailFactory::makeRecoveryMailerService($form->email);
|
||||
|
||||
if ($this->make(PasswordRecoveryService::class, [$form->email, $mailService])->run()) {
|
||||
|
||||
$this->trigger(FormEvent::EVENT_AFTER_REQUEST, $event);
|
||||
|
||||
return $this->render(
|
||||
@ -100,7 +99,7 @@ class RecoveryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('request', ['model' => $form,]);
|
||||
return $this->render('request', ['model' => $form]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,6 +109,7 @@ class RecoveryController extends Controller
|
||||
* @param $code
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionReset($id, $code)
|
||||
@ -159,6 +159,6 @@ class RecoveryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('reset', ['model' => $form,]);
|
||||
return $this->render('reset', ['model' => $form]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Event\FormEvent;
|
||||
@ -34,11 +35,11 @@ class RegistrationController extends Controller
|
||||
/**
|
||||
* RegistrationController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param UserQuery $userQuery
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param UserQuery $userQuery
|
||||
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(
|
||||
$id,
|
||||
@ -47,14 +48,13 @@ class RegistrationController extends Controller
|
||||
SocialNetworkAccountQuery $socialNetworkAccountQuery,
|
||||
array $config = []
|
||||
) {
|
||||
|
||||
$this->userQuery = $userQuery;
|
||||
$this->socialNetworkAccountQuery = $socialNetworkAccountQuery;
|
||||
parent::__construct($id, $module, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -65,12 +65,12 @@ class RegistrationController extends Controller
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['register', 'connect'],
|
||||
'roles' => ['?']
|
||||
'roles' => ['?'],
|
||||
],
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['confirm', 'resend'],
|
||||
'roles' => ['?', '@']
|
||||
'roles' => ['?', '@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -97,7 +97,6 @@ class RegistrationController extends Controller
|
||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||
|
||||
if ($this->make(UserRegisterService::class, [$user, $mailService])->run()) {
|
||||
|
||||
Yii::$app->session->setFlash(
|
||||
'info',
|
||||
Yii::t(
|
||||
@ -110,7 +109,7 @@ class RegistrationController extends Controller
|
||||
'/shared/message',
|
||||
[
|
||||
'title' => Yii::t('user', 'Your account has been created'),
|
||||
'module' => $this->module
|
||||
'module' => $this->module,
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -143,7 +142,6 @@ class RegistrationController extends Controller
|
||||
$this->make(AjaxRequestModelValidator::class, [$user])->validate();
|
||||
|
||||
if ($user->load(Yii::$app->request->post())) {
|
||||
|
||||
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT, $event);
|
||||
|
||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||
@ -225,7 +223,7 @@ class RegistrationController extends Controller
|
||||
'info',
|
||||
Yii::t(
|
||||
'user',
|
||||
'A message has been sent to your email address. ' .
|
||||
'A message has been sent to your email address. '.
|
||||
'It contains a confirmation link that you must click to complete registration.'
|
||||
)
|
||||
);
|
||||
@ -236,14 +234,14 @@ class RegistrationController extends Controller
|
||||
'danger',
|
||||
Yii::t(
|
||||
'user',
|
||||
'We couldn\'t re-send the mail to confirm your address. ' .
|
||||
'We couldn\'t re-send the mail to confirm your address. '.
|
||||
'Please, verify is the correct email or if it has been confirmed already.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render('/shared/message', [
|
||||
'title' => $success
|
||||
'title' => $success
|
||||
? Yii::t('user', 'A new confirmation link has been sent')
|
||||
: Yii::t('user', 'Unable to send confirmation link'),
|
||||
'module' => $this->module,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Model\Role;
|
||||
@ -8,7 +9,7 @@ use yii\web\NotFoundHttpException;
|
||||
class RoleController extends AbstractAuthItemController
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getModelClass()
|
||||
{
|
||||
@ -16,7 +17,7 @@ class RoleController extends AbstractAuthItemController
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getSearchModelClass()
|
||||
{
|
||||
@ -24,7 +25,7 @@ class RoleController extends AbstractAuthItemController
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getItem($name)
|
||||
{
|
||||
@ -36,5 +37,4 @@ class RoleController extends AbstractAuthItemController
|
||||
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
@ -10,11 +11,9 @@ use Da\User\Service\SocialNetworkAccountConnectService;
|
||||
use Da\User\Service\SocialNetworkAuthenticateService;
|
||||
use Da\User\Traits\ContainerTrait;
|
||||
use yii\authclient\AuthAction;
|
||||
use yii\authclient\ClientInterface;
|
||||
use yii\base\Module;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\Controller;
|
||||
use Yii;
|
||||
|
||||
@ -27,10 +26,10 @@ class SecurityController extends Controller
|
||||
/**
|
||||
* SecurityController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(
|
||||
$id,
|
||||
@ -43,7 +42,7 @@ class SecurityController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -54,12 +53,12 @@ class SecurityController extends Controller
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['login', 'auth', 'blocked'],
|
||||
'roles' => ['?']
|
||||
'roles' => ['?'],
|
||||
],
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['login', 'auth', 'logout'],
|
||||
'roles' => ['@']
|
||||
'roles' => ['@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -73,7 +72,7 @@ class SecurityController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Controller;
|
||||
|
||||
use Da\User\Contracts\MailChangeStrategyInterface;
|
||||
@ -24,7 +25,6 @@ use Yii;
|
||||
use yii\web\ForbiddenHttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
use ContainerTrait;
|
||||
@ -34,19 +34,19 @@ class SettingsController extends Controller
|
||||
protected $socialNetworkAccountQuery;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $defaultAction = 'profile';
|
||||
|
||||
/**
|
||||
* SettingsController constructor.
|
||||
*
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param ProfileQuery $profileQuery
|
||||
* @param UserQuery $userQuery
|
||||
* @param string $id
|
||||
* @param Module $module
|
||||
* @param ProfileQuery $profileQuery
|
||||
* @param UserQuery $userQuery
|
||||
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(
|
||||
$id,
|
||||
@ -63,7 +63,7 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
@ -196,7 +196,6 @@ class SettingsController extends Controller
|
||||
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event);
|
||||
|
||||
return $this->redirect(['networks']);
|
||||
|
||||
}
|
||||
|
||||
public function actionDelete()
|
||||
|
||||
Reference in New Issue
Block a user