fix formatting

This commit is contained in:
Antonio Ramirez
2016-12-14 02:50:12 +01:00
parent f3f4b31bb4
commit 3ba01b4674
140 changed files with 512 additions and 523 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -6,7 +7,7 @@ use Da\User\Contracts\AuthClientInterface;
class Facebook extends \yii\authclient\clients\Facebook implements AuthClientInterface class Facebook extends \yii\authclient\clients\Facebook implements AuthClientInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getEmail() public function getEmail()
{ {
@ -16,7 +17,7 @@ class Facebook extends \yii\authclient\clients\Facebook implements AuthClientInt
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getUsername() public function getUsername()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -6,7 +7,7 @@ use Da\User\Contracts\AuthClientInterface;
class GitHub extends \yii\authclient\clients\GitHub implements AuthClientInterface class GitHub extends \yii\authclient\clients\GitHub implements AuthClientInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getEmail() public function getEmail()
{ {
@ -16,7 +17,7 @@ class GitHub extends \yii\authclient\clients\GitHub implements AuthClientInterfa
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getUsername() public function getUsername()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -6,7 +7,7 @@ use Da\User\Contracts\AuthClientInterface;
class Google extends \yii\authclient\clients\Google implements AuthClientInterface class Google extends \yii\authclient\clients\Google implements AuthClientInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getEmail() public function getEmail()
{ {
@ -16,7 +17,7 @@ class Google extends \yii\authclient\clients\Google implements AuthClientInterfa
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getUsername() public function getUsername()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -6,7 +7,7 @@ use Da\User\Contracts\AuthClientInterface;
class LinkedIn extends \yii\authclient\clients\LinkedIn implements AuthClientInterface class LinkedIn extends \yii\authclient\clients\LinkedIn implements AuthClientInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getEmail() public function getEmail()
{ {
@ -16,7 +17,7 @@ class LinkedIn extends \yii\authclient\clients\LinkedIn implements AuthClientInt
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getUsername() public function getUsername()
{ {

View File

@ -1,9 +1,9 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
class Twitter extends \yii\authclient\clients\Twitter implements AuthClientInterface class Twitter extends \yii\authclient\clients\Twitter implements AuthClientInterface
{ {
/** /**
@ -16,9 +16,6 @@ class Twitter extends \yii\authclient\clients\Twitter implements AuthClientInter
: null; : null;
} }
/**
* @return null Twitter does not provide user's email address
*/
public function getEmail() public function getEmail()
{ {
return null; return null;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -7,12 +8,12 @@ use Yii;
class VKontakte extends \yii\authclient\clients\VKontakte implements AuthClientInterface class VKontakte extends \yii\authclient\clients\VKontakte implements AuthClientInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public $scope = 'email'; public $scope = 'email';
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getEmail() public function getEmail()
{ {
@ -20,7 +21,7 @@ class VKontakte extends \yii\authclient\clients\VKontakte implements AuthClientI
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getUsername() public function getUsername()
{ {
@ -30,7 +31,7 @@ class VKontakte extends \yii\authclient\clients\VKontakte implements AuthClientI
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function defaultTitle() protected function defaultTitle()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\AuthClient; namespace Da\User\AuthClient;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -7,7 +8,7 @@ use Yii;
class Yandex extends \yii\authclient\clients\Yandex implements AuthClientInterface class Yandex extends \yii\authclient\clients\Yandex implements AuthClientInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getEmail() public function getEmail()
{ {
@ -23,7 +24,7 @@ class Yandex extends \yii\authclient\clients\Yandex implements AuthClientInterfa
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getUsername() public function getUsername()
{ {
@ -33,7 +34,7 @@ class Yandex extends \yii\authclient\clients\Yandex implements AuthClientInterfa
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function defaultTitle() protected function defaultTitle()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User; namespace Da\User;
use Da\User\Component\AuthDbManagerComponent; use Da\User\Component\AuthDbManagerComponent;
@ -18,7 +19,7 @@ use yii\web\Application as WebApplication;
class Bootstrap implements BootstrapInterface class Bootstrap implements BootstrapInterface
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function bootstrap($app) public function bootstrap($app)
{ {
@ -34,14 +35,14 @@ class Bootstrap implements BootstrapInterface
$this->initAuthCollection($app); $this->initAuthCollection($app);
$this->initAuthManager($app); $this->initAuthManager($app);
} else { } else {
/** @var $app ConsoleApplication */ /* @var $app ConsoleApplication */
$this->initConsoleCommands($app); $this->initConsoleCommands($app);
} }
} }
} }
/** /**
* Initialize container with module classes * Initialize container with module classes.
* *
* @param \yii\base\Application $app * @param \yii\base\Application $app
* @param array $map the previously built class map list * @param array $map the previously built class map list
@ -131,7 +132,7 @@ class Bootstrap implements BootstrapInterface
[ [
'enableAutoLogin' => true, 'enableAutoLogin' => true,
'loginUrl' => ['/user/auth/login'], 'loginUrl' => ['/user/auth/login'],
'identityClass' => $di->get(ClassMapHelper::class)->get(User::class) 'identityClass' => $di->get(ClassMapHelper::class)->get(User::class),
] ]
); );
} }
@ -141,7 +142,7 @@ class Bootstrap implements BootstrapInterface
} }
/** /**
* Registers module translation messages * Registers module translation messages.
* *
* @param Application $app * @param Application $app
*/ */
@ -151,7 +152,7 @@ class Bootstrap implements BootstrapInterface
$app->get('i18n')->translations['user*'] = [ $app->get('i18n')->translations['user*'] = [
'class' => PhpMessageSource::class, 'class' => PhpMessageSource::class,
'basePath' => __DIR__.'/resources/i18n', 'basePath' => __DIR__.'/resources/i18n',
'sourceLanguage' => 'en-US' 'sourceLanguage' => 'en-US',
]; ];
} }
} }
@ -167,14 +168,14 @@ class Bootstrap implements BootstrapInterface
$app->set( $app->set(
'authManager', 'authManager',
[ [
'class' => AuthDbManagerComponent::class 'class' => AuthDbManagerComponent::class,
] ]
); );
} }
} }
/** /**
* Initializes web url routes (rules in Yii2) * Initializes web url routes (rules in Yii2).
* *
* @param WebApplication $app * @param WebApplication $app
*/ */
@ -209,7 +210,7 @@ class Bootstrap implements BootstrapInterface
'welcomeMailSubject' => Yii::t('user', 'Welcome to {0}', $app->name), 'welcomeMailSubject' => Yii::t('user', 'Welcome to {0}', $app->name),
'confirmationMailSubject' => Yii::t('user', 'Confirm account on {0}', $app->name), 'confirmationMailSubject' => Yii::t('user', 'Confirm account on {0}', $app->name),
'reconfirmationMailSubject' => Yii::t('user', 'Confirm email change on {0}', $app->name), 'reconfirmationMailSubject' => Yii::t('user', 'Confirm email change on {0}', $app->name),
'recoveryMailSubject' => Yii::t('user', 'Complete password reset on {0}', $app->name) 'recoveryMailSubject' => Yii::t('user', 'Complete password reset on {0}', $app->name),
]; ];
$module->mailParams = array_merge($defaults, $module->mailParams); $module->mailParams = array_merge($defaults, $module->mailParams);
@ -238,7 +239,7 @@ class Bootstrap implements BootstrapInterface
} }
/** /**
* Registers controllers * Registers controllers.
* *
* @param WebApplication $app * @param WebApplication $app
*/ */
@ -249,7 +250,7 @@ class Bootstrap implements BootstrapInterface
} }
/** /**
* Builds class map according to user configuration * Builds class map according to user configuration.
* *
* @param array $userClassMap user configuration on the module * @param array $userClassMap user configuration on the module
* *
@ -288,12 +289,12 @@ class Bootstrap implements BootstrapInterface
'Token', 'Token',
'Assignment', 'Assignment',
'Permission', 'Permission',
'Role' 'Role',
], ],
'Da\User\Search' => [ 'Da\User\Search' => [
'UserSearch', 'UserSearch',
'PermissionSearch', 'PermissionSearch',
'RoleSearch' 'RoleSearch',
], ],
'Da\UserForm' => [ 'Da\UserForm' => [
'RegistrationForm', 'RegistrationForm',
@ -301,7 +302,7 @@ class Bootstrap implements BootstrapInterface
'LoginForm', 'LoginForm',
'SettingsForm', 'SettingsForm',
'RecoveryForm', 'RecoveryForm',
] ],
]; ];
$mapping = array_merge($defaults, $userClassMap); $mapping = array_merge($defaults, $userClassMap);
@ -314,12 +315,13 @@ class Bootstrap implements BootstrapInterface
} }
/** /**
* Returns the parent class name route of a short class name * Returns the parent class name route of a short class name.
* *
* @param array $routes class name routes * @param array $routes class name routes
* @param string $name * @param string $name
* *
* @return int|string * @return int|string
*
* @throws Exception * @throws Exception
*/ */
protected function getRoute(array $routes, $name) protected function getRoute(array $routes, $name)
@ -331,5 +333,4 @@ class Bootstrap implements BootstrapInterface
} }
throw new Exception("Unknown configuration class name '{$name}'"); throw new Exception("Unknown configuration class name '{$name}'");
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Command; namespace Da\User\Command;
use Da\User\Query\UserQuery; use Da\User\Query\UserQuery;
@ -28,7 +29,6 @@ class ConfirmController extends Controller
if ($user === null) { if ($user === null) {
$this->stdout(Yii::t('user', 'User is not found')."\n", Console::FG_RED); $this->stdout(Yii::t('user', 'User is not found')."\n", Console::FG_RED);
} else { } else {
if ($this->make(UserConfirmationService::class, [$user])->run()) { if ($this->make(UserConfirmationService::class, [$user])->run()) {
$this->stdout(Yii::t('user', 'User has been confirmed')."\n", Console::FG_GREEN); $this->stdout(Yii::t('user', 'User has been confirmed')."\n", Console::FG_GREEN);
} else { } else {
@ -37,5 +37,3 @@ class ConfirmController extends Controller
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Command; namespace Da\User\Command;
use Da\User\Factory\MailFactory; use Da\User\Factory\MailFactory;
@ -31,6 +32,5 @@ class CreateController extends Controller
} }
} }
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Command; namespace Da\User\Command;
use Da\User\Query\UserQuery; use Da\User\Query\UserQuery;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Command; namespace Da\User\Command;
use Da\User\Model\User; use Da\User\Model\User;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Component;
namespace Da\User\Component;
use Da\User\Contracts\AuthManagerInterface; use Da\User\Contracts\AuthManagerInterface;
use yii\db\Query; use yii\db\Query;
@ -9,8 +9,8 @@ use yii\rbac\DbManager;
class AuthDbManagerComponent extends DbManager implements AuthManagerInterface class AuthDbManagerComponent extends DbManager implements AuthManagerInterface
{ {
/** /**
* @param int|null $type If null will return all auth items. * @param int|null $type If null will return all auth items
* @param array $excludeItems Items that should be excluded from result array. * @param array $excludeItems Items that should be excluded from result array
* *
* @return array * @return array
*/ */
@ -40,7 +40,7 @@ class AuthDbManagerComponent extends DbManager implements AuthManagerInterface
/** /**
* Returns both roles and permissions assigned to user. * Returns both roles and permissions assigned to user.
* *
* @param integer $userId * @param int $userId
* *
* @return array * @return array
*/ */
@ -66,7 +66,7 @@ class AuthDbManagerComponent extends DbManager implements AuthManagerInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getItem($name) public function getItem($name)
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Contracts; namespace Da\User\Contracts;
use yii\authclient\ClientInterface; use yii\authclient\ClientInterface;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Contracts; namespace Da\User\Contracts;
use yii\rbac\ManagerInterface; use yii\rbac\ManagerInterface;
@ -6,7 +7,7 @@ use yii\rbac\ManagerInterface;
interface AuthManagerInterface extends ManagerInterface interface AuthManagerInterface extends ManagerInterface
{ {
/** /**
* @param integer|null $type * @param int|null $type
* @param array $excludeItems * @param array $excludeItems
* *
* @return mixed * @return mixed
@ -14,7 +15,7 @@ interface AuthManagerInterface extends ManagerInterface
public function getItems($type = null, $excludeItems = []); public function getItems($type = null, $excludeItems = []);
/** /**
* @param integer $userId * @param int $userId
* *
* @return mixed * @return mixed
*/ */

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Contracts; namespace Da\User\Contracts;
interface MailChangeStrategyInterface extends StrategyInterface interface MailChangeStrategyInterface extends StrategyInterface

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Contracts; namespace Da\User\Contracts;
interface ServiceInterface interface ServiceInterface

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Contracts; namespace Da\User\Contracts;
interface StrategyInterface interface StrategyInterface

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Contracts; namespace Da\User\Contracts;
interface ValidatorInterface interface ValidatorInterface

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Filter\AccessRuleFilter; use Da\User\Filter\AccessRuleFilter;
@ -35,7 +36,7 @@ abstract class AbstractAuthItemController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -63,7 +64,7 @@ abstract class AbstractAuthItemController extends Controller
'index', 'index',
[ [
'searchModel' => $searchModel, '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.')); ->setFlash('success', Yii::t('user', 'Authorization item successfully created.'));
return $this->redirect(['index']); return $this->redirect(['index']);
} else { } else {
Yii::$app->getSession()->setFlash('danger', Yii::t('user', 'Unable to create authorization item.')); Yii::$app->getSession()->setFlash('danger', Yii::t('user', 'Unable to create authorization item.'));
} }
@ -92,7 +92,7 @@ abstract class AbstractAuthItemController extends Controller
'create', 'create',
[ [
'model' => $model, '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(); $this->make(AjaxRequestModelValidator::class, [$model])->validate();
if ($model->load(Yii::$app->request->post())) { if ($model->load(Yii::$app->request->post())) {
if ($this->make(AuthItemEditionService::class, [$model])->run()) { if ($this->make(AuthItemEditionService::class, [$model])->run()) {
Yii::$app Yii::$app
->getSession() ->getSession()
->setFlash('success', Yii::t('user', 'Authorization item successfully updated.')); ->setFlash('success', Yii::t('user', 'Authorization item successfully updated.'));
return $this->redirect(['index']); return $this->redirect(['index']);
} else { } else {
Yii::$app->getSession()->setFlash('danger', Yii::t('user', 'Unable to update authorization item.')); Yii::$app->getSession()->setFlash('danger', Yii::t('user', 'Unable to update authorization item.'));
} }
@ -124,7 +122,7 @@ abstract class AbstractAuthItemController extends Controller
'update', 'update',
[ [
'model' => $model, '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 * @return string
*/ */
abstract protected function getModelClass(); abstract protected function getModelClass();
/** /**
* The fully qualified class name of the search model * The fully qualified class name of the search model.
* *
* @return string * @return string
*/ */
abstract protected function getSearchModelClass(); abstract protected function getSearchModelClass();
/** /**
* Returns the an auth item * Returns the an auth item.
* *
* @param string $name * @param string $name
* *
* @return \yii\rbac\Role|\yii\rbac\Permission|\yii\rbac\Rule * @return \yii\rbac\Role|\yii\rbac\Permission|\yii\rbac\Rule
*/ */
abstract protected function getItem($name); abstract protected function getItem($name);
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Event\UserEvent; use Da\User\Event\UserEvent;
@ -21,7 +22,6 @@ use yii\filters\VerbFilter;
use yii\helpers\Url; use yii\helpers\Url;
use yii\web\Controller; use yii\web\Controller;
class AdminController extends Controller class AdminController extends Controller
{ {
use ContainerTrait; use ContainerTrait;
@ -60,7 +60,7 @@ class AdminController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -97,7 +97,7 @@ class AdminController extends Controller
'index', 'index',
[ [
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'searchModel' => $searchModel 'searchModel' => $searchModel,
] ]
); );
} }
@ -113,13 +113,11 @@ class AdminController extends Controller
$this->make(AjaxRequestModelValidator::class, [$user])->validate(); $this->make(AjaxRequestModelValidator::class, [$user])->validate();
if ($user->load(Yii::$app->request->post())) { if ($user->load(Yii::$app->request->post())) {
$this->trigger(UserEvent::EVENT_BEFORE_CREATE, $event); $this->trigger(UserEvent::EVENT_BEFORE_CREATE, $event);
$mailService = MailFactory::makeWelcomeMailerService($user); $mailService = MailFactory::makeWelcomeMailerService($user);
if ($this->make(UserCreateService::class, [$user, $mailService])->run()) { if ($this->make(UserCreateService::class, [$user, $mailService])->run()) {
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created')); Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created'));
$this->trigger(UserEvent::EVENT_AFTER_CREATE, $event); $this->trigger(UserEvent::EVENT_AFTER_CREATE, $event);
@ -181,7 +179,7 @@ class AdminController extends Controller
'_profile', '_profile',
[ [
'user' => $user, 'user' => $user,
'profile' => $profile 'profile' => $profile,
] ]
); );
} }
@ -208,7 +206,7 @@ class AdminController extends Controller
'_assignments', '_assignments',
[ [
'user' => $user, '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()) { if ($this->make(UserConfirmationService::class, [$user])->run()) {
Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been confirmed')); Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been confirmed'));
$this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event); $this->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);
} else { } else {
Yii::$app->getSession()->setFlash('warning', Yii::t('user', 'Unable to confirm user. Please, try again.')); 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()) { if ($user->delete()) {
Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been deleted')); Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been deleted'));
$this->trigger(ActiveRecord::EVENT_AFTER_DELETE, $event); $this->trigger(ActiveRecord::EVENT_AFTER_DELETE, $event);
} else { } else {
Yii::$app->getSession()->setFlash( Yii::$app->getSession()->setFlash(
'warning', 'warning',
@ -279,4 +275,3 @@ class AdminController extends Controller
return $this->redirect(Url::previous('actions-redirect')); return $this->redirect(Url::previous('actions-redirect'));
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Controller;
namespace Da\User\Controller;
use Da\User\Model\Permission; use Da\User\Model\Permission;
use Da\User\Search\PermissionSearch; use Da\User\Search\PermissionSearch;
@ -9,7 +9,7 @@ use yii\web\NotFoundHttpException;
class PermissionController extends AbstractAuthItemController class PermissionController extends AbstractAuthItemController
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getModelClass() protected function getModelClass()
{ {
@ -17,7 +17,7 @@ class PermissionController extends AbstractAuthItemController
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getSearchModelClass() protected function getSearchModelClass()
{ {
@ -25,7 +25,7 @@ class PermissionController extends AbstractAuthItemController
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getItem($name) protected function getItem($name)
{ {
@ -37,5 +37,4 @@ class PermissionController extends AbstractAuthItemController
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Query\ProfileQuery; use Da\User\Query\ProfileQuery;
@ -27,7 +28,7 @@ class ProfileController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -38,12 +39,12 @@ class ProfileController extends Controller
[ [
'allow' => true, 'allow' => true,
'actions' => ['index'], 'actions' => ['index'],
'roles' => ['@'] 'roles' => ['@'],
], ],
[ [
'allow' => true, 'allow' => true,
'actions' => ['show'], 'actions' => ['show'],
'roles' => ['?', '@'] 'roles' => ['?', '@'],
], ],
], ],
], ],
@ -70,5 +71,4 @@ class ProfileController extends Controller
] ]
); );
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Event\FormEvent; use Da\User\Event\FormEvent;
@ -42,7 +43,7 @@ class RecoveryController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -53,7 +54,7 @@ class RecoveryController extends Controller
[ [
'allow' => true, 'allow' => true,
'actions' => ['request', 'reset'], 'actions' => ['request', 'reset'],
'roles' => ['?'] 'roles' => ['?'],
], ],
], ],
], ],
@ -64,11 +65,11 @@ class RecoveryController extends Controller
* Displays / handles user password recovery request. * Displays / handles user password recovery request.
* *
* @return string * @return string
*
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionRequest() public function actionRequest()
{ {
if (!$this->module->allowPasswordRecovery) { if (!$this->module->allowPasswordRecovery) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
@ -81,13 +82,11 @@ class RecoveryController extends Controller
$this->make(AjaxRequestModelValidator::class, $form)->validate(); $this->make(AjaxRequestModelValidator::class, $form)->validate();
if ($form->load(Yii::$app->request->post())) { if ($form->load(Yii::$app->request->post())) {
$this->trigger(FormEvent::EVENT_BEFORE_REQUEST, $event); $this->trigger(FormEvent::EVENT_BEFORE_REQUEST, $event);
$mailService = MailFactory::makeRecoveryMailerService($form->email); $mailService = MailFactory::makeRecoveryMailerService($form->email);
if ($this->make(PasswordRecoveryService::class, [$form->email, $mailService])->run()) { if ($this->make(PasswordRecoveryService::class, [$form->email, $mailService])->run()) {
$this->trigger(FormEvent::EVENT_AFTER_REQUEST, $event); $this->trigger(FormEvent::EVENT_AFTER_REQUEST, $event);
return $this->render( 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 * @param $code
* *
* @return string * @return string
*
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */
public function actionReset($id, $code) 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]);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Event\FormEvent; use Da\User\Event\FormEvent;
@ -47,14 +48,13 @@ class RegistrationController extends Controller
SocialNetworkAccountQuery $socialNetworkAccountQuery, SocialNetworkAccountQuery $socialNetworkAccountQuery,
array $config = [] array $config = []
) { ) {
$this->userQuery = $userQuery; $this->userQuery = $userQuery;
$this->socialNetworkAccountQuery = $socialNetworkAccountQuery; $this->socialNetworkAccountQuery = $socialNetworkAccountQuery;
parent::__construct($id, $module, $config); parent::__construct($id, $module, $config);
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -65,12 +65,12 @@ class RegistrationController extends Controller
[ [
'allow' => true, 'allow' => true,
'actions' => ['register', 'connect'], 'actions' => ['register', 'connect'],
'roles' => ['?'] 'roles' => ['?'],
], ],
[ [
'allow' => true, 'allow' => true,
'actions' => ['confirm', 'resend'], 'actions' => ['confirm', 'resend'],
'roles' => ['?', '@'] 'roles' => ['?', '@'],
], ],
], ],
], ],
@ -97,7 +97,6 @@ class RegistrationController extends Controller
$mailService = MailFactory::makeWelcomeMailerService($user); $mailService = MailFactory::makeWelcomeMailerService($user);
if ($this->make(UserRegisterService::class, [$user, $mailService])->run()) { if ($this->make(UserRegisterService::class, [$user, $mailService])->run()) {
Yii::$app->session->setFlash( Yii::$app->session->setFlash(
'info', 'info',
Yii::t( Yii::t(
@ -110,7 +109,7 @@ class RegistrationController extends Controller
'/shared/message', '/shared/message',
[ [
'title' => Yii::t('user', 'Your account has been created'), '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(); $this->make(AjaxRequestModelValidator::class, [$user])->validate();
if ($user->load(Yii::$app->request->post())) { if ($user->load(Yii::$app->request->post())) {
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT, $event); $this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT, $event);
$mailService = MailFactory::makeWelcomeMailerService($user); $mailService = MailFactory::makeWelcomeMailerService($user);

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Model\Role; use Da\User\Model\Role;
@ -8,7 +9,7 @@ use yii\web\NotFoundHttpException;
class RoleController extends AbstractAuthItemController class RoleController extends AbstractAuthItemController
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getModelClass() protected function getModelClass()
{ {
@ -16,7 +17,7 @@ class RoleController extends AbstractAuthItemController
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getSearchModelClass() protected function getSearchModelClass()
{ {
@ -24,7 +25,7 @@ class RoleController extends AbstractAuthItemController
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
protected function getItem($name) protected function getItem($name)
{ {
@ -36,5 +37,4 @@ class RoleController extends AbstractAuthItemController
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -10,11 +11,9 @@ use Da\User\Service\SocialNetworkAccountConnectService;
use Da\User\Service\SocialNetworkAuthenticateService; use Da\User\Service\SocialNetworkAuthenticateService;
use Da\User\Traits\ContainerTrait; use Da\User\Traits\ContainerTrait;
use yii\authclient\AuthAction; use yii\authclient\AuthAction;
use yii\authclient\ClientInterface;
use yii\base\Module; use yii\base\Module;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\Url;
use yii\web\Controller; use yii\web\Controller;
use Yii; use Yii;
@ -43,7 +42,7 @@ class SecurityController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -54,12 +53,12 @@ class SecurityController extends Controller
[ [
'allow' => true, 'allow' => true,
'actions' => ['login', 'auth', 'blocked'], 'actions' => ['login', 'auth', 'blocked'],
'roles' => ['?'] 'roles' => ['?'],
], ],
[ [
'allow' => true, 'allow' => true,
'actions' => ['login', 'auth', 'logout'], 'actions' => ['login', 'auth', 'logout'],
'roles' => ['@'] 'roles' => ['@'],
], ],
], ],
], ],
@ -73,7 +72,7 @@ class SecurityController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function actions() public function actions()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Controller; namespace Da\User\Controller;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
@ -24,7 +25,6 @@ use Yii;
use yii\web\ForbiddenHttpException; use yii\web\ForbiddenHttpException;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
class SettingsController extends Controller class SettingsController extends Controller
{ {
use ContainerTrait; use ContainerTrait;
@ -34,7 +34,7 @@ class SettingsController extends Controller
protected $socialNetworkAccountQuery; protected $socialNetworkAccountQuery;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public $defaultAction = 'profile'; public $defaultAction = 'profile';
@ -63,7 +63,7 @@ class SettingsController extends Controller
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -196,7 +196,6 @@ class SettingsController extends Controller
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event); $this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event);
return $this->redirect(['networks']); return $this->redirect(['networks']);
} }
public function actionDelete() public function actionDelete()

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Event; namespace Da\User\Event;
use yii\base\Event; use yii\base\Event;
@ -26,4 +27,3 @@ class FormEvent extends Event
return $this->form; return $this->form;
} }
} }

View File

@ -1,17 +1,16 @@
<?php <?php
namespace Da\User\Event; namespace Da\User\Event;
use Da\User\Model\Profile; use Da\User\Model\Profile;
use yii\base\Event; use yii\base\Event;
class ProfileEvent extends Event class ProfileEvent extends Event
{ {
protected $profile; protected $profile;
public function __construct(Profile $profile, array $config = []) public function __construct(Profile $profile, array $config = [])
{ {
$this->profile = $profile; $this->profile = $profile;
return parent::__construct($config); return parent::__construct($config);

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Event;
namespace Da\User\Event;
use Da\User\Form\RecoveryForm; use Da\User\Form\RecoveryForm;
use Da\User\Model\Token; use Da\User\Model\Token;

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Da\User\Event; namespace Da\User\Event;
use Da\User\Model\SocialNetworkAccount; use Da\User\Model\SocialNetworkAccount;
use yii\authclient\ClientInterface; use yii\authclient\ClientInterface;
use yii\base\Event; use yii\base\Event;
class SocialNetworkAuthEvent extends Event class SocialNetworkAuthEvent extends Event
{ {
const EVENT_BEFORE_AUTHENTICATE = 'beforeAuthenticate'; const EVENT_BEFORE_AUTHENTICATE = 'beforeAuthenticate';

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Da\User\Event; namespace Da\User\Event;
use Da\User\Model\SocialNetworkAccount; use Da\User\Model\SocialNetworkAccount;
use Da\User\Model\User; use Da\User\Model\User;
use yii\base\Event; use yii\base\Event;
class SocialNetworkConnectEvent extends Event class SocialNetworkConnectEvent extends Event
{ {
const EVENT_BEFORE_CONNECT = 'beforeConnect'; const EVENT_BEFORE_CONNECT = 'beforeConnect';

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Event; namespace Da\User\Event;
use Da\User\Model\User; use Da\User\Model\User;
@ -25,7 +26,6 @@ class UserEvent extends Event
const EVENT_BEFORE_LOGOUT = 'beforeLogout'; const EVENT_BEFORE_LOGOUT = 'beforeLogout';
const EVENT_AFTER_LOGOUT = 'afterLogout'; const EVENT_AFTER_LOGOUT = 'afterLogout';
protected $user; protected $user;
public function __construct(User $user, array $config = []) public function __construct(User $user, array $config = [])

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Factory; namespace Da\User\Factory;
use Yii; use Yii;
@ -9,7 +10,7 @@ class AuthItemFactory
{ {
protected static $map = [ protected static $map = [
Item::TYPE_ROLE => 'makeRole', Item::TYPE_ROLE => 'makeRole',
Item::TYPE_PERMISSION => 'makePermission' Item::TYPE_PERMISSION => 'makePermission',
]; ];
/** /**
@ -37,6 +38,7 @@ class AuthItemFactory
* @param $name * @param $name
* *
* @return \yii\rbac\Role|\yii\rbac\Permission * @return \yii\rbac\Role|\yii\rbac\Permission
*
* @throws Exception * @throws Exception
*/ */
public static function makeByType($type, $name) public static function makeByType($type, $name)

View File

@ -1,8 +1,8 @@
<?php <?php
namespace Da\User\Factory; namespace Da\User\Factory;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
use Da\User\Contracts\StrategyInterface;
use Da\User\Form\SettingsForm; use Da\User\Form\SettingsForm;
use Da\User\Strategy\DefaultEmailChangeStrategy; use Da\User\Strategy\DefaultEmailChangeStrategy;
use Da\User\Strategy\InsecureEmailChangeStrategy; use Da\User\Strategy\InsecureEmailChangeStrategy;
@ -12,11 +12,10 @@ use Exception;
class EmailChangeStrategyFactory class EmailChangeStrategyFactory
{ {
protected static $map = [ protected static $map = [
MailChangeStrategyInterface::TYPE_INSECURE => InsecureEmailChangeStrategy::class, MailChangeStrategyInterface::TYPE_INSECURE => InsecureEmailChangeStrategy::class,
MailChangeStrategyInterface::TYPE_DEFAULT => DefaultEmailChangeStrategy::class, MailChangeStrategyInterface::TYPE_DEFAULT => DefaultEmailChangeStrategy::class,
MailChangeStrategyInterface::TYPE_SECURE => SecureEmailChangeStrategy::class MailChangeStrategyInterface::TYPE_SECURE => SecureEmailChangeStrategy::class,
]; ];
/** /**
@ -24,6 +23,7 @@ class EmailChangeStrategyFactory
* @param SettingsForm $form * @param SettingsForm $form
* *
* @return MailChangeStrategyInterface * @return MailChangeStrategyInterface
*
* @throws Exception * @throws Exception
*/ */
public static function makeByStrategyType($strategy, SettingsForm $form) public static function makeByStrategyType($strategy, SettingsForm $form)

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Factory; namespace Da\User\Factory;
use Da\User\Model\Token; use Da\User\Model\Token;
@ -25,7 +26,7 @@ class MailFactory
'user' => $user, 'user' => $user,
'token' => null, 'token' => null,
'module' => $module, 'module' => $module,
'showPassword' => false 'showPassword' => false,
]; ];
return static::makeMailerService($from, $to, $subject, 'welcome', $params); return static::makeMailerService($from, $to, $subject, 'welcome', $params);
@ -46,7 +47,7 @@ class MailFactory
$subject = $module->mailParams['recoveryMailSubject']; $subject = $module->mailParams['recoveryMailSubject'];
$params = [ $params = [
'user' => $token && $token->user ? $token->user : null, 'user' => $token && $token->user ? $token->user : null,
'token' => $token 'token' => $token,
]; ];
return static::makeMailerService($from, $to, $subject, 'recovery', $params); return static::makeMailerService($from, $to, $subject, 'recovery', $params);
@ -67,7 +68,7 @@ class MailFactory
$subject = $module->mailParams['confirmationMailSubject']; $subject = $module->mailParams['confirmationMailSubject'];
$params = [ $params = [
'user' => $token && $token->user ? $token->user : null, 'user' => $token && $token->user ? $token->user : null,
'token' => $token 'token' => $token,
]; ];
return static::makeMailerService($from, $to, $subject, 'recovery', $params); return static::makeMailerService($from, $to, $subject, 'recovery', $params);
@ -79,7 +80,8 @@ class MailFactory
* *
* @return MailService * @return MailService
*/ */
public static function makeReconfirmationMailerService(User $user, Token $token) { public static function makeReconfirmationMailerService(User $user, Token $token)
{
/** @var Module $module */ /** @var Module $module */
$module = Yii::$app->getModule('user'); $module = Yii::$app->getModule('user');
$to = $token->type === Token::TYPE_CONFIRM_NEW_EMAIL $to = $token->type === Token::TYPE_CONFIRM_NEW_EMAIL
@ -90,14 +92,14 @@ class MailFactory
$subject = $module->mailParams['reconfirmationMailSubject']; $subject = $module->mailParams['reconfirmationMailSubject'];
$params = [ $params = [
'user' => $token && $token->user ? $token->user : null, 'user' => $token && $token->user ? $token->user : null,
'token' => $token 'token' => $token,
]; ];
return static::makeMailerService($from, $to, $subject, 'recovery', $params); return static::makeMailerService($from, $to, $subject, 'recovery', $params);
} }
/** /**
* Builds a MailerService * Builds a MailerService.
* *
* @param string $from * @param string $from
* @param string $to * @param string $to

View File

@ -1,13 +1,12 @@
<?php <?php
namespace Da\User\Factory; namespace Da\User\Factory;
use Da\User\Model\Token; use Da\User\Model\Token;
use Yii; use Yii;
class TokenFactory class TokenFactory
{ {
/** /**
* @param $userId * @param $userId
* *
@ -20,7 +19,6 @@ class TokenFactory
$token->save(false); $token->save(false);
return $token; return $token;
} }
/** /**
@ -75,5 +73,4 @@ class TokenFactory
{ {
return Yii::createObject(['class' => Token::class, 'user_id' => $userId, 'type' => $type]); return Yii::createObject(['class' => Token::class, 'user_id' => $userId, 'type' => $type]);
} }
} }

View File

@ -5,11 +5,10 @@ namespace Da\User\Filter;
use Da\User\Model\User; use Da\User\Model\User;
use yii\filters\AccessRule; use yii\filters\AccessRule;
class AccessRuleFilter extends AccessRule class AccessRuleFilter extends AccessRule
{ {
/** /**
* @inheritdoc * {@inheritdoc}
* */ * */
protected function matchRole($user) protected function matchRole($user)
{ {

View File

@ -51,7 +51,7 @@ class LoginForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -63,7 +63,7 @@ class LoginForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
@ -78,7 +78,7 @@ class LoginForm extends Model
) { ) {
$this->addError($attribute, Yii::t('user', 'Invalid login or password')); $this->addError($attribute, Yii::t('user', 'Invalid login or password'));
} }
} },
], ],
'confirmationValidate' => [ 'confirmationValidate' => [
'login', 'login',
@ -93,7 +93,7 @@ class LoginForm extends Model
$this->addError($attribute, Yii::t('user', 'Your account has been blocked')); $this->addError($attribute, Yii::t('user', 'Your account has been blocked'));
} }
} }
} },
], ],
'rememberMe' => ['rememberMe', 'boolean'], 'rememberMe' => ['rememberMe', 'boolean'],
]; ];
@ -108,6 +108,7 @@ class LoginForm extends Model
{ {
if ($this->validate()) { if ($this->validate()) {
$duration = $this->rememberMe ? $this->module->rememberLoginLifespan : 0; $duration = $this->rememberMe ? $this->module->rememberLoginLifespan : 0;
return Yii::$app->getUser()->login($this->user, $duration); return Yii::$app->getUser()->login($this->user, $duration);
} else { } else {
return false; return false;
@ -115,14 +116,16 @@ class LoginForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function beforeValidate() public function beforeValidate()
{ {
if (parent::beforeValidate()) { if (parent::beforeValidate()) {
$this->user = $this->query->whereUsernameOrEmail(trim($this->login))->one(); $this->user = $this->query->whereUsernameOrEmail(trim($this->login))->one();
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Form; namespace Da\User\Form;
use Da\User\Query\UserQuery; use Da\User\Query\UserQuery;
@ -37,7 +38,7 @@ class RecoveryForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -48,7 +49,7 @@ class RecoveryForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function scenarios() public function scenarios()
{ {
@ -59,7 +60,7 @@ class RecoveryForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {

View File

@ -8,7 +8,6 @@ use Da\User\Traits\ModuleTrait;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;
class RegistrationForm extends Model class RegistrationForm extends Model
{ {
use ModuleTrait; use ModuleTrait;
@ -28,7 +27,7 @@ class RegistrationForm extends Model
public $password; public $password;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
@ -45,7 +44,7 @@ class RegistrationForm extends Model
'username', 'username',
'unique', 'unique',
'targetClass' => $user, 'targetClass' => $user,
'message' => Yii::t('user', 'This username has already been taken') 'message' => Yii::t('user', 'This username has already been taken'),
], ],
// email rules // email rules
'emailTrim' => ['email', 'filter', 'filter' => 'trim'], 'emailTrim' => ['email', 'filter', 'filter' => 'trim'],
@ -55,7 +54,7 @@ class RegistrationForm extends Model
'email', 'email',
'unique', 'unique',
'targetClass' => $user, 'targetClass' => $user,
'message' => Yii::t('user', 'This email address has already been taken') 'message' => Yii::t('user', 'This email address has already been taken'),
], ],
// password rules // password rules
'passwordRequired' => ['password', 'required', 'skipOnEmpty' => $this->module->generatePasswords], 'passwordRequired' => ['password', 'required', 'skipOnEmpty' => $this->module->generatePasswords],
@ -64,7 +63,7 @@ class RegistrationForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Form; namespace Da\User\Form;
use Da\User\Query\UserQuery; use Da\User\Query\UserQuery;
@ -27,7 +28,7 @@ class ResendForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
@ -38,7 +39,7 @@ class ResendForm extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {

View File

@ -64,7 +64,7 @@ class SettingsForm extends Model
'when' => function ($model, $attribute) { 'when' => function ($model, $attribute) {
return $this->getUser()->$attribute != $model->$attribute; return $this->getUser()->$attribute != $model->$attribute;
}, },
'targetClass' => $this->getClassMap()->get(User::class) 'targetClass' => $this->getClassMap()->get(User::class),
], ],
'newPasswordLength' => ['new_password', 'string', 'max' => 72, 'min' => 6], 'newPasswordLength' => ['new_password', 'string', 'max' => 72, 'min' => 6],
'currentPasswordRequired' => ['current_password', 'required'], 'currentPasswordRequired' => ['current_password', 'required'],
@ -74,13 +74,13 @@ class SettingsForm extends Model
if (!$this->securityHelper->validatePassword($this->$attribute, $this->getUser()->password_hash)) { if (!$this->securityHelper->validatePassword($this->$attribute, $this->getUser()->password_hash)) {
$this->addError($attribute, Yii::t('user', 'Current password is not valid')); $this->addError($attribute, Yii::t('user', 'Current password is not valid'));
} }
} },
], ],
]; ];
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -117,7 +117,6 @@ class SettingsForm extends Model
$this->user->password = $this->new_password; $this->user->password = $this->new_password;
if ($this->email == $this->user->email && $this->user->unconfirmed_email != null) { if ($this->email == $this->user->email && $this->user->unconfirmed_email != null) {
$this->user->unconfirmed_email = null; $this->user->unconfirmed_email = null;
} elseif ($this->email != $this->user->email) { } elseif ($this->email != $this->user->email) {
$strategy = EmailChangeStrategyFactory::makeByStrategyType( $strategy = EmailChangeStrategyFactory::makeByStrategyType(
$this->getModule()->emailChangeStrategy, $this->getModule()->emailChangeStrategy,

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Helper; namespace Da\User\Helper;
use Da\User\Model\AbstractAuthItem; use Da\User\Model\AbstractAuthItem;
@ -15,7 +16,7 @@ class AuthHelper
use AuthManagerTrait; use AuthManagerTrait;
/** /**
* Checks whether a user has certain role * Checks whether a user has certain role.
* *
* @param $userId * @param $userId
* @param $role * @param $role

View File

@ -3,11 +3,11 @@
namespace Da\User\Helper; namespace Da\User\Helper;
/** /**
* * ModelMapHelper.php.
* ModelMapHelper.php
* *
* Date: 3/12/16 * Date: 3/12/16
* Time: 18:10 * Time: 18:10
*
* @author Antonio Ramirez <hola@2amigos.us> * @author Antonio Ramirez <hola@2amigos.us>
*/ */
class ClassMapHelper class ClassMapHelper
@ -37,13 +37,14 @@ class ClassMapHelper
* @param $key * @param $key
* *
* @return mixed * @return mixed
*
* @throws \Exception * @throws \Exception
*/ */
public function get($key) public function get($key)
{ {
if (array_key_exists($key, $this->map)) { if (array_key_exists($key, $this->map)) {
return $this->map[$key]; return $this->map[$key];
}; }
throw new \Exception('Unknown model map key: '.$key); throw new \Exception('Unknown model map key: '.$key);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Helper; namespace Da\User\Helper;
class GravatarHelper class GravatarHelper

View File

@ -54,7 +54,7 @@ class SecurityHelper
} }
$all = str_split($all); $all = str_split($all);
for ($i = 0; $i < $length - count($sets); $i++) { for ($i = 0; $i < $length - count($sets); ++$i) {
$password .= $all[array_rand($all)]; $password .= $all[array_rand($all)];
} }

View File

@ -1,15 +1,15 @@
<?php <?php
namespace Da\User\Helper; namespace Da\User\Helper;
use DateTimeZone; use DateTimeZone;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use DateTime; use DateTime;
class TimezoneHelper class TimezoneHelper
{ {
/** /**
* Get all of the time zones with the offsets sorted by their offset * Get all of the time zones with the offsets sorted by their offset.
* *
* @return array * @return array
*/ */
@ -24,7 +24,7 @@ class TimezoneHelper
$timeZones[] = [ $timeZones[] = [
'timezone' => $timeZone, 'timezone' => $timeZone,
'name' => "{$timeZone} (UTC ".($offset > 0 ? '+' : '')."{$offset})", 'name' => "{$timeZone} (UTC ".($offset > 0 ? '+' : '')."{$offset})",
'offset' => $offset 'offset' => $offset,
]; ];
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Migration; namespace Da\User\Migration;
use yii\db\Migration; use yii\db\Migration;
@ -19,7 +20,7 @@ class m000000_000001_create_user_table extends Migration
'confirmed_at' => $this->integer(), 'confirmed_at' => $this->integer(),
'blocked_at' => $this->integer(), 'blocked_at' => $this->integer(),
'updated_at' => $this->integer()->notNull(), 'updated_at' => $this->integer()->notNull(),
'created_at' => $this->integer()->notNull() 'created_at' => $this->integer()->notNull(),
]); ]);
$this->createIndex('idx_user_username', '{{%user}}', 'username', true); $this->createIndex('idx_user_username', '{{%user}}', 'username', true);

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Migration; namespace Da\User\Migration;
use yii\db\Migration; use yii\db\Migration;
@ -18,7 +19,7 @@ class m000000_000002_create_profile_table extends Migration
'location' => $this->string(255), 'location' => $this->string(255),
'website' => $this->string(255), 'website' => $this->string(255),
'timezone' => $this->string(40), 'timezone' => $this->string(40),
'bio' => $this->text() 'bio' => $this->text(),
] ]
); );

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Migration; namespace Da\User\Migration;
use yii\db\Migration; use yii\db\Migration;
@ -18,7 +19,7 @@ class m000000_000003_create_social_account_table extends Migration
'email' => $this->string(255), 'email' => $this->string(255),
'username' => $this->string(255), 'username' => $this->string(255),
'data' => $this->text(), 'data' => $this->text(),
'created_at' => $this->integer() 'created_at' => $this->integer(),
] ]
); );

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Migration; namespace Da\User\Migration;
use yii\db\Migration; use yii\db\Migration;
@ -13,7 +14,7 @@ class m000000_000004_create_token_table extends Migration
'user_id' => $this->integer(), 'user_id' => $this->integer(),
'code' => $this->string(32)->notNull(), 'code' => $this->string(32)->notNull(),
'type' => $this->smallInteger(6)->notNull(), 'type' => $this->smallInteger(6)->notNull(),
'created_at' => $this->integer()->notNull() 'created_at' => $this->integer()->notNull(),
] ]
); );

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use Da\User\Traits\AuthManagerTrait; use Da\User\Traits\AuthManagerTrait;
@ -38,7 +39,7 @@ abstract class AbstractAuthItem extends Model
public $item; public $item;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function init() public function init()
{ {
@ -56,7 +57,7 @@ abstract class AbstractAuthItem extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -69,7 +70,7 @@ abstract class AbstractAuthItem extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function scenarios() public function scenarios()
{ {
@ -80,7 +81,7 @@ abstract class AbstractAuthItem extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
@ -98,7 +99,7 @@ abstract class AbstractAuthItem extends Model
}, },
'when' => function () { 'when' => function () {
return $this->scenario == 'create' || $this->item->name != $this->name; return $this->scenario == 'create' || $this->item->name != $this->name;
} },
], ],
['children', RbacItemsValidator::class], ['children', RbacItemsValidator::class],
['rule', RbacRuleValidator::class], ['rule', RbacRuleValidator::class],

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use Da\User\Traits\AuthManagerTrait; use Da\User\Traits\AuthManagerTrait;
@ -16,7 +17,8 @@ class Assignment extends Model
public $updated = false; public $updated = false;
/** /**
* @inheritdoc * {@inheritdoc}
*
* @throws InvalidConfigException * @throws InvalidConfigException
*/ */
public function init() public function init()
@ -31,24 +33,24 @@ class Assignment extends Model
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
return [ return [
'items' => Yii::t('user', 'Items') 'items' => Yii::t('user', 'Items'),
]; ];
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
return [ return [
['user_id', 'required'], ['user_id', 'required'],
['items', RbacItemsValidator::class], ['items', RbacItemsValidator::class],
['user_id', 'integer'] ['user_id', 'integer'],
]; ];
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use yii\rbac\Item; use yii\rbac\Item;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use Da\User\Helper\GravatarHelper; use Da\User\Helper\GravatarHelper;
@ -13,8 +14,7 @@ use DateTimeZone;
use DateTime; use DateTime;
/** /**
* * @property int $user_id
* @property integer $user_id
* @property string $name * @property string $name
* @property string $public_email * @property string $public_email
* @property string $gravatar_email * @property string $gravatar_email
@ -23,7 +23,6 @@ use DateTime;
* @property string $website * @property string $website
* @property string $bio * @property string $bio
* @property string $timezone * @property string $timezone
*
* @property User $user * @property User $user
*/ */
class Profile extends ActiveRecord class Profile extends ActiveRecord
@ -32,12 +31,11 @@ class Profile extends ActiveRecord
use ContainerTrait; use ContainerTrait;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function beforeSave($insert) public function beforeSave($insert)
{ {
if ($this->isAttributeChanged('gravatar_email')) { if ($this->isAttributeChanged('gravatar_email')) {
$this->setAttribute( $this->setAttribute(
'gravatar_id', 'gravatar_id',
$this->make(GravatarHelper::class)->buildId(trim($this->getAttribute('gravatar_email'))) $this->make(GravatarHelper::class)->buildId(trim($this->getAttribute('gravatar_email')))
@ -48,7 +46,7 @@ class Profile extends ActiveRecord
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function tableName() public static function tableName()
{ {
@ -56,7 +54,7 @@ class Profile extends ActiveRecord
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
@ -68,7 +66,7 @@ class Profile extends ActiveRecord
if ($this->make(TimeZoneValidator::class, [$attribute])->validate()) { if ($this->make(TimeZoneValidator::class, [$attribute])->validate()) {
$this->addError($attribute, Yii::t('user', 'Time zone is not valid')); $this->addError($attribute, Yii::t('user', 'Time zone is not valid'));
} }
} },
], ],
'publicEmailPattern' => ['public_email', 'email'], 'publicEmailPattern' => ['public_email', 'email'],
'gravatarEmailPattern' => ['gravatar_email', 'email'], 'gravatarEmailPattern' => ['gravatar_email', 'email'],
@ -82,7 +80,7 @@ class Profile extends ActiveRecord
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -112,7 +110,7 @@ class Profile extends ActiveRecord
} }
/** /**
* Set the User's timezone * Set the User's timezone.
* *
* @param DateTimeZone $timezone * @param DateTimeZone $timezone
*/ */
@ -122,7 +120,7 @@ class Profile extends ActiveRecord
} }
/** /**
* Get User's local time * Get User's local time.
* *
* @param DateTime|null $dateTime * @param DateTime|null $dateTime
* *

View File

@ -1,9 +1,9 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use yii\rbac\Item; use yii\rbac\Item;
class Role extends AbstractAuthItem class Role extends AbstractAuthItem
{ {
public function getType() public function getType()

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use Da\User\Query\SocialNetworkAccountQuery; use Da\User\Query\SocialNetworkAccountQuery;
@ -10,8 +11,8 @@ use yii\helpers\Url;
/** /**
* /** * /**
* @property integer $id Id * @property int $id Id
* @property integer $user_id User id, null if account is not bind to user * @property int $user_id User id, null if account is not bind to user
* @property string $provider Name of service * @property string $provider Name of service
* @property string $client_id Account id * @property string $client_id Account id
* @property string $data Account properties returned by social network (json encoded) * @property string $data Account properties returned by social network (json encoded)
@ -19,9 +20,8 @@ use yii\helpers\Url;
* @property string $code * @property string $code
* @property string $email * @property string $email
* @property string $username * @property string $username
* @property integer $created_at * @property int $created_at
* * @property User $user User that this account is connected for
* @property User $user User that this account is connected for.
*/ */
class SocialNetworkAccount extends ActiveRecord class SocialNetworkAccount extends ActiveRecord
{ {
@ -34,7 +34,7 @@ class SocialNetworkAccount extends ActiveRecord
protected $decodedData; protected $decodedData;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function tableName() public static function tableName()
{ {
@ -42,7 +42,7 @@ class SocialNetworkAccount extends ActiveRecord
} }
/** /**
* @return bool Whether this social account is connected to user. * @return bool Whether this social account is connected to user
*/ */
public function getIsConnected() public function getIsConnected()
{ {
@ -73,7 +73,7 @@ class SocialNetworkAccount extends ActiveRecord
} }
/** /**
* Connects account to a user * Connects account to a user.
* *
* @param User $user * @param User $user
* *

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use Da\User\Helper\SecurityHelper; use Da\User\Helper\SecurityHelper;
@ -8,18 +9,16 @@ use Da\User\Traits\ModuleTrait;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
use yii\helpers\Url; use yii\helpers\Url;
use RuntimeException; use RuntimeException;
use Yii;
/** /**
* Token Active Record model. * Token Active Record model.
* *
* @property integer $user_id * @property int $user_id
* @property string $code * @property string $code
* @property integer $type * @property int $type
* @property string $url * @property string $url
* @property bool $isExpired * @property bool $isExpired
* @property integer $created_at * @property int $created_at
*
* @property User $user * @property User $user
*/ */
class Token extends ActiveRecord class Token extends ActiveRecord
@ -36,11 +35,11 @@ class Token extends ActiveRecord
self::TYPE_CONFIRMATION => '/user/registration/confirm', self::TYPE_CONFIRMATION => '/user/registration/confirm',
self::TYPE_RECOVERY => '/usr/recovery/reset', self::TYPE_RECOVERY => '/usr/recovery/reset',
self::TYPE_CONFIRM_NEW_EMAIL => '/user/settings/confirm', self::TYPE_CONFIRM_NEW_EMAIL => '/user/settings/confirm',
self::TYPE_CONFIRM_OLD_EMAIL => '/usr/settings/confirm' self::TYPE_CONFIRM_OLD_EMAIL => '/usr/settings/confirm',
]; ];
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function beforeSave($insert) public function beforeSave($insert)
{ {
@ -54,7 +53,7 @@ class Token extends ActiveRecord
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function tableName() public static function tableName()
{ {
@ -62,7 +61,7 @@ class Token extends ActiveRecord
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function primaryKey() public static function primaryKey()
{ {
@ -86,7 +85,7 @@ class Token extends ActiveRecord
} }
/** /**
* @return bool Whether token has expired. * @return bool Whether token has expired
*/ */
public function getIsExpired() public function getIsExpired()
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Model; namespace Da\User\Model;
use Da\User\Helper\SecurityHelper; use Da\User\Helper\SecurityHelper;
@ -21,18 +22,18 @@ use yii\web\IdentityInterface;
* @property bool $isConfirmed * @property bool $isConfirmed
* *
* Database fields: * Database fields:
* @property integer $id * @property int $id
* @property string $username * @property string $username
* @property string $email * @property string $email
* @property string $unconfirmed_email * @property string $unconfirmed_email
* @property string $password_hash * @property string $password_hash
* @property string $auth_key * @property string $auth_key
* @property integer $registration_ip * @property int $registration_ip
* @property integer $confirmed_at * @property int $confirmed_at
* @property integer $blocked_at * @property int $blocked_at
* @property integer $flags * @property int $flags
* @property integer $created_at * @property int $created_at
* @property integer $updated_at * @property int $updated_at
* *
* Defined relations: * Defined relations:
* @property SocialNetworkAccount[] $socialNetworkAccounts * @property SocialNetworkAccount[] $socialNetworkAccounts
@ -48,7 +49,7 @@ class User extends ActiveRecord implements IdentityInterface
const NEW_EMAIL_CONFIRMED = 0b10; const NEW_EMAIL_CONFIRMED = 0b10;
/** /**
* @var string Plain password. Used for model validation. * @var string Plain password. Used for model validation
*/ */
public $password; public $password;
/** /**
@ -57,7 +58,7 @@ class User extends ActiveRecord implements IdentityInterface
protected $connectedAccounts; protected $connectedAccounts;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function beforeSave($insert) public function beforeSave($insert)
{ {
@ -81,7 +82,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function tableName() public static function tableName()
{ {
@ -89,7 +90,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function behaviors() public function behaviors()
{ {
@ -99,7 +100,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -115,7 +116,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function scenarios() public function scenarios()
{ {
@ -132,7 +133,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function rules() public function rules()
{ {
@ -145,7 +146,7 @@ class User extends ActiveRecord implements IdentityInterface
'usernameUnique' => [ 'usernameUnique' => [
'username', 'username',
'unique', 'unique',
'message' => Yii::t('user', 'This username has already been taken') 'message' => Yii::t('user', 'This username has already been taken'),
], ],
// email rules // email rules
@ -155,7 +156,7 @@ class User extends ActiveRecord implements IdentityInterface
'emailUnique' => [ 'emailUnique' => [
'email', 'email',
'unique', 'unique',
'message' => Yii::t('user', 'This email address has already been taken') 'message' => Yii::t('user', 'This email address has already been taken'),
], ],
'emailTrim' => ['email', 'trim'], 'emailTrim' => ['email', 'trim'],
@ -166,7 +167,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function validateAuthKey($authKey) public function validateAuthKey($authKey)
{ {
@ -174,7 +175,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getId() public function getId()
{ {
@ -182,7 +183,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getAuthKey() public function getAuthKey()
{ {
@ -190,7 +191,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function findIdentity($id) public static function findIdentity($id)
{ {
@ -198,7 +199,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @return bool whether is blocked or not. * @return bool whether is blocked or not
*/ */
public function getIsBlocked() public function getIsBlocked()
{ {
@ -222,7 +223,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* Checks whether a user has a specific role * Checks whether a user has a specific role.
* *
* @param string $role * @param string $role
* *
@ -269,7 +270,7 @@ class User extends ActiveRecord implements IdentityInterface
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public static function findIdentityByAccessToken($token, $type = null) public static function findIdentityByAccessToken($token, $type = null)
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User; namespace Da\User;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
@ -6,11 +7,11 @@ use Da\User\Contracts\MailChangeStrategyInterface;
class Module extends \yii\base\Module class Module extends \yii\base\Module
{ {
/** /**
* @var bool whether to allow registration process or not. * @var bool whether to allow registration process or not
*/ */
public $enableRegistration = true; public $enableRegistration = true;
/** /**
* @var bool whether to force email confirmation to. * @var bool whether to force email confirmation to
*/ */
public $enableEmailConfirmation = true; public $enableEmailConfirmation = true;
/** /**
@ -18,15 +19,15 @@ class Module extends \yii\base\Module
*/ */
public $enableFlashMessages = true; public $enableFlashMessages = true;
/** /**
* @var bool whether to generate passwords automatically and remove the password field from the registration form. * @var bool whether to generate passwords automatically and remove the password field from the registration form
*/ */
public $generatePasswords = false; public $generatePasswords = false;
/** /**
* @var bool whether to allow login accounts with unconfirmed emails. * @var bool whether to allow login accounts with unconfirmed emails
*/ */
public $allowUnconfirmedEmailLogin = false; public $allowUnconfirmedEmailLogin = false;
/** /**
* @var bool whether to enable password recovery or not. * @var bool whether to enable password recovery or not
*/ */
public $allowPasswordRecovery = true; public $allowPasswordRecovery = true;
/** /**
@ -34,19 +35,19 @@ class Module extends \yii\base\Module
*/ */
public $allowAccountDelete = false; public $allowAccountDelete = false;
/** /**
* @var string the class name of the strategy class to handle user's email change. * @var string the class name of the strategy class to handle user's email change
*/ */
public $emailChangeStrategy = MailChangeStrategyInterface::TYPE_DEFAULT; public $emailChangeStrategy = MailChangeStrategyInterface::TYPE_DEFAULT;
/** /**
* @var int the time user will be auto logged in. * @var int the time user will be auto logged in
*/ */
public $rememberLoginLifespan = 1209600; public $rememberLoginLifespan = 1209600;
/** /**
* @var int the time before the confirmation token becomes invalid. Defaults to 24 hours. * @var int the time before the confirmation token becomes invalid. Defaults to 24 hours
*/ */
public $tokenConfirmationLifespan = 86400; public $tokenConfirmationLifespan = 86400;
/** /**
* @var int the time before a recovery token is invalid. Defaults to 6 hours. * @var int the time before a recovery token is invalid. Defaults to 6 hours
*/ */
public $tokenRecoveryLifespan = 21600; public $tokenRecoveryLifespan = 21600;
/** /**
@ -71,11 +72,11 @@ class Module extends \yii\base\Module
* the longer it takes to generate the hash and to verify a password against it. Higher cost * the longer it takes to generate the hash and to verify a password against it. Higher cost
* therefore slows down a brute-force attack. For best protection against brute-force attacks, * therefore slows down a brute-force attack. For best protection against brute-force attacks,
* set it to the highest value that is tolerable on production servers. The time taken to * set it to the highest value that is tolerable on production servers. The time taken to
* compute the hash doubles for every increment by one of $cost. * compute the hash doubles for every increment by one of $cost
*/ */
public $blowfishCost = 10; public $blowfishCost = 10;
/** /**
* @var array the class map. How the container should load specific classes. * @var array the class map. How the container should load specific classes
*/ */
public $classMap = []; public $classMap = [];
@ -89,7 +90,7 @@ class Module extends \yii\base\Module
'confirm/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'registration/confirm', 'confirm/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'registration/confirm',
'forgot' => 'recovery/request', 'forgot' => 'recovery/request',
'recover/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'recovery/reset', 'recover/<id:\d+>/<code:[A-Za-z0-9_-]+>' => 'recovery/reset',
'settings/<action:\w+>' => 'settings/<action>' 'settings/<action:\w+>' => 'settings/<action>',
]; ];
public $viewPath = '@Da/User/resources/views'; public $viewPath = '@Da/User/resources/views';

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Query; namespace Da\User\Query;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Query; namespace Da\User\Query;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
@ -16,7 +17,7 @@ class SocialNetworkAccountQuery extends ActiveQuery
return $this->andWhere( return $this->andWhere(
[ [
'provider' => $client->getId(), 'provider' => $client->getId(),
'client_id' => $client->getUserAttributes()['id'] 'client_id' => $client->getUserAttributes()['id'],
] ]
); );
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Query; namespace Da\User\Query;
use Da\User\Model\Token; use Da\User\Model\Token;

View File

@ -48,7 +48,6 @@ class UserQuery extends ActiveQuery
return $this->andWhere(['id' => $id]); return $this->andWhere(['id' => $id]);
} }
/** /**
* @param $id * @param $id
* *

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Search; namespace Da\User\Search;
use Da\User\Traits\AuthManagerTrait; use Da\User\Traits\AuthManagerTrait;
@ -26,7 +27,7 @@ abstract class AbstractAuthItemSearch extends Model
public $rule_name; public $rule_name;
/** /**
* @return integer * @return int
*/ */
abstract public function getType(); abstract public function getType();
@ -60,6 +61,5 @@ abstract class AbstractAuthItemSearch extends Model
$dataProvider->allModels = $query->all($this->getAuthManager()->db); $dataProvider->allModels = $query->all($this->getAuthManager()->db);
return $dataProvider; return $dataProvider;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Search; namespace Da\User\Search;
use yii\rbac\Item; use yii\rbac\Item;
@ -6,11 +7,10 @@ use yii\rbac\Item;
class PermissionSearch extends AbstractAuthItemSearch class PermissionSearch extends AbstractAuthItemSearch
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getType() public function getType()
{ {
return Item::TYPE_PERMISSION; return Item::TYPE_PERMISSION;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Search; namespace Da\User\Search;
use yii\rbac\Item; use yii\rbac\Item;
@ -6,7 +7,7 @@ use yii\rbac\Item;
class RoleSearch extends AbstractAuthItemSearch class RoleSearch extends AbstractAuthItemSearch
{ {
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function getType() public function getType()
{ {

View File

@ -1,9 +1,8 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
use Da\User\Event\UserEvent;
use Da\User\Model\Token; use Da\User\Model\Token;
use Da\User\Model\User; use Da\User\Model\User;
use Da\User\Query\TokenQuery; use Da\User\Query\TokenQuery;
@ -43,5 +42,4 @@ class AccountConfirmationService implements ServiceInterface
return false; return false;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -55,14 +56,13 @@ class AuthItemEditionService implements ServiceInterface
$this->model->item = $item; $this->model->item = $item;
return $this->updateChildren(); return $this->updateChildren();
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
} }
/** /**
* Updates Auth Item children * Updates Auth Item children.
* *
* @return bool * @return bool
*/ */
@ -78,7 +78,6 @@ class AuthItemEditionService implements ServiceInterface
if (!$this->getAuthManager()->removeChild($this->model->item, $children[$item])) { if (!$this->getAuthManager()->removeChild($this->model->item, $children[$item])) {
return false; return false;
} }
} }
// add new children // add new children
foreach (array_diff($this->model->children, $childrenNames) as $item) { foreach (array_diff($this->model->children, $childrenNames) as $item) {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
@ -44,9 +45,7 @@ class EmailChangeService implements ServiceInterface
$token->delete(); $token->delete();
if (empty($this->model->unconfirmed_email)) { if (empty($this->model->unconfirmed_email)) {
Yii::$app->session->setFlash('danger', Yii::t('user', 'An error occurred processing your request')); Yii::$app->session->setFlash('danger', Yii::t('user', 'An error occurred processing your request'));
} elseif ($this->userQuery->whereEmail($this->model->unconfirmed_email)->exists() === false) { } elseif ($this->userQuery->whereEmail($this->model->unconfirmed_email)->exists() === false) {
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_SECURE) { if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_SECURE) {
if ($token->type === Token::TYPE_CONFIRM_NEW_EMAIL) { if ($token->type === Token::TYPE_CONFIRM_NEW_EMAIL) {
$this->model->flags |= User::NEW_EMAIL_CONFIRMED; $this->model->flags |= User::NEW_EMAIL_CONFIRMED;
@ -81,7 +80,7 @@ class EmailChangeService implements ServiceInterface
return $this->model->save(false); return $this->model->save(false);
} }
} }
return false; return false;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -51,12 +52,10 @@ class PasswordRecoveryService implements ServiceInterface
); );
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR); $this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
return false; return false;
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
use Da\User\Factory\TokenFactory; use Da\User\Factory\TokenFactory;
@ -31,5 +31,4 @@ class ResendConfirmationService implements ServiceInterface
return false; return false;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
use Da\User\Helper\SecurityHelper; use Da\User\Helper\SecurityHelper;
@ -21,12 +21,10 @@ class ResetPasswordService implements ServiceInterface
public function run() public function run()
{ {
return $this->model && (bool) $this->model->updateAttributes( return $this->model && (bool) $this->model->updateAttributes(
[ [
'password_hash' => $this->securityHelper->generatePasswordHash($this->password) 'password_hash' => $this->securityHelper->generatePasswordHash($this->password),
] ]
); );
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -12,7 +12,6 @@ use Da\User\Query\SocialNetworkAccountQuery;
use Da\User\Traits\ContainerTrait; use Da\User\Traits\ContainerTrait;
use Yii; use Yii;
class SocialNetworkAccountConnectService implements ServiceInterface class SocialNetworkAccountConnectService implements ServiceInterface
{ {
use ContainerTrait; use ContainerTrait;
@ -54,7 +53,6 @@ class SocialNetworkAccountConnectService implements ServiceInterface
$this->controller->trigger(SocialNetworkAuthEvent::EVENT_AFTER_CONNECT, $event); $this->controller->trigger(SocialNetworkAuthEvent::EVENT_AFTER_CONNECT, $event);
return true; return true;
} else { } else {
Yii::$app->session->setFlash( Yii::$app->session->setFlash(
'danger', 'danger',
@ -77,7 +75,7 @@ class SocialNetworkAccountConnectService implements ServiceInterface
[ [
'provider' => $this->client->getId(), 'provider' => $this->client->getId(),
'client_id' => $data['id'], 'client_id' => $data['id'],
'data' => json_encode($data) 'data' => json_encode($data),
] ]
); );

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\AuthClientInterface; use Da\User\Contracts\AuthClientInterface;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -17,7 +17,6 @@ use yii\helpers\Url;
class SocialNetworkAuthenticateService implements ServiceInterface class SocialNetworkAuthenticateService implements ServiceInterface
{ {
protected $controller; protected $controller;
protected $authAction; protected $authAction;
protected $client; protected $client;
@ -38,7 +37,6 @@ class SocialNetworkAuthenticateService implements ServiceInterface
$this->userQuery = $userQuery; $this->userQuery = $userQuery;
} }
public function run() public function run()
{ {
$account = $this->socialNetworkAccountQuery->whereClient($this->client)->one(); $account = $this->socialNetworkAccountQuery->whereClient($this->client)->one();
@ -87,7 +85,7 @@ class SocialNetworkAuthenticateService implements ServiceInterface
'client_id' => $data['id'], 'client_id' => $data['id'],
'data' => json_encode($data), 'data' => json_encode($data),
'username' => $this->client->getUserName(), 'username' => $this->client->getUserName(),
'email' => $this->client->getEmail() 'email' => $this->client->getEmail(),
] ]
); );
@ -113,7 +111,7 @@ class SocialNetworkAuthenticateService implements ServiceInterface
[ [
'scenario' => 'connect', 'scenario' => 'connect',
'username' => $account->username, 'username' => $account->username,
'email' => $account->email 'email' => $account->email,
] ]
); );

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Service;
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
use Da\User\Model\Assignment; use Da\User\Model\Assignment;
@ -39,6 +39,5 @@ class UpdateAuthAssignmentsService implements ServiceInterface
} }
return $this->model->updated = true; return $this->model->updated = true;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -39,6 +40,7 @@ class UserBlockService implements ServiceInterface
); );
$this->controller->trigger(UserEvent::EVENT_AFTER_BLOCK, $this->event); $this->controller->trigger(UserEvent::EVENT_AFTER_BLOCK, $this->event);
} }
return $result; return $result;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -22,6 +23,7 @@ class UserConfirmationService implements ServiceInterface
return true; return true;
} }
return false; return false;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -7,7 +8,6 @@ use Da\User\Helper\SecurityHelper;
use Da\User\Model\User; use Da\User\Model\User;
use yii\base\InvalidCallException; use yii\base\InvalidCallException;
use Exception; use Exception;
use yii\db\ActiveRecord;
use yii\log\Logger; use yii\log\Logger;
class UserCreateService implements ServiceInterface class UserCreateService implements ServiceInterface
@ -58,14 +58,11 @@ class UserCreateService implements ServiceInterface
$transaction->commit(); $transaction->commit();
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$transaction->rollBack(); $transaction->rollBack();
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR); $this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
return false; return false;
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
@ -49,6 +50,7 @@ class UserRegisterService implements ServiceInterface
if (!$model->save()) { if (!$model->save()) {
$transaction->rollBack(); $transaction->rollBack();
return false; return false;
} }
@ -66,7 +68,6 @@ class UserRegisterService implements ServiceInterface
$transaction->commit(); $transaction->commit();
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$transaction->rollBack(); $transaction->rollBack();
$this->logger->log($e->getMessage(), Logger::LEVEL_WARNING); $this->logger->log($e->getMessage(), Logger::LEVEL_WARNING);
@ -74,5 +75,4 @@ class UserRegisterService implements ServiceInterface
return false; return false;
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Strategy; namespace Da\User\Strategy;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
@ -17,7 +18,6 @@ class DefaultEmailChangeStrategy implements MailChangeStrategyInterface
public function __construct(SettingsForm $form) public function __construct(SettingsForm $form)
{ {
$this->form = $form; $this->form = $form;
} }
public function run() public function run()
@ -37,7 +37,5 @@ class DefaultEmailChangeStrategy implements MailChangeStrategyInterface
} }
return false; return false;
} }
} }

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Da\User\Strategy; namespace Da\User\Strategy;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
use Da\User\Form\SettingsForm; use Da\User\Form\SettingsForm;
class InsecureEmailChangeStrategy implements MailChangeStrategyInterface class InsecureEmailChangeStrategy implements MailChangeStrategyInterface
{ {
protected $form; protected $form;
@ -17,7 +17,7 @@ class InsecureEmailChangeStrategy implements MailChangeStrategyInterface
public function run() public function run()
{ {
$this->form->getUser()->email = $this->form->email; $this->form->getUser()->email = $this->form->email;
return $this->form->getUser()->save(); return $this->form->getUser()->save();
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Strategy; namespace Da\User\Strategy;
use Da\User\Contracts\MailChangeStrategyInterface; use Da\User\Contracts\MailChangeStrategyInterface;
@ -18,13 +19,11 @@ class SecureEmailChangeStrategy implements MailChangeStrategyInterface
public function __construct(SettingsForm $form) public function __construct(SettingsForm $form)
{ {
$this->form = $form; $this->form = $form;
} }
public function run() public function run()
{ {
if ($this->make(DefaultEmailChangeStrategy::class, [$this->form])->run()) { if ($this->make(DefaultEmailChangeStrategy::class, [$this->form])->run()) {
$token = TokenFactory::makeConfirmOldMailToken($this->form->getUser()->id); $token = TokenFactory::makeConfirmOldMailToken($this->form->getUser()->id);
$mailService = MailFactory::makeReconfirmationMailerService($this->form->getUser(), $token); $mailService = MailFactory::makeReconfirmationMailerService($this->form->getUser(), $token);
@ -51,5 +50,4 @@ class SecureEmailChangeStrategy implements MailChangeStrategyInterface
return false; return false;
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Traits; namespace Da\User\Traits;
use Da\User\Component\AuthDbManagerComponent; use Da\User\Component\AuthDbManagerComponent;
@ -9,8 +10,8 @@ trait AuthManagerTrait
/** /**
* @return AuthDbManagerComponent|\yii\rbac\ManagerInterface * @return AuthDbManagerComponent|\yii\rbac\ManagerInterface
*/ */
public function getAuthManager() { public function getAuthManager()
{
return Yii::$app->getAuthManager(); return Yii::$app->getAuthManager();
} }
} }

View File

@ -8,11 +8,9 @@ use Yii;
use yii\di\Container; use yii\di\Container;
/** /**
*
* @property-read Container $di * @property-read Container $di
* @property-ready Da\User\Helper\AuthHelper $auth * @property-ready Da\User\Helper\AuthHelper $auth
* @property-ready Da\User\Helper\ClassMapHelper $classMap * @property-ready Da\User\Helper\ClassMapHelper $classMap
*
*/ */
trait ContainerTrait trait ContainerTrait
{ {
@ -28,8 +26,7 @@ trait ContainerTrait
* Gets a class from the container. * Gets a class from the container.
* *
* @param string $class he class name or an alias name (e.g. `foo`) that was previously registered via [[set()]] * @param string $class he class name or an alias name (e.g. `foo`) that was previously registered via [[set()]]
* or [[setSingleton()]]. * or [[setSingleton()]]
*
* @param array $params constructor parameters * @param array $params constructor parameters
* @param array $config attributes * @param array $config attributes
* *
@ -55,5 +52,4 @@ trait ContainerTrait
{ {
return $this->getDi()->get(ClassMapHelper::class); return $this->getDi()->get(ClassMapHelper::class);
} }
} }

View File

@ -2,7 +2,6 @@
namespace Da\User\Traits; namespace Da\User\Traits;
use Da\User\Helper\AuthHelper;
use Da\User\Module; use Da\User\Module;
use Yii; use Yii;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Validator; namespace Da\User\Validator;
use Da\User\Contracts\ValidatorInterface; use Da\User\Contracts\ValidatorInterface;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Validator; namespace Da\User\Validator;
use Da\User\Traits\AuthManagerTrait; use Da\User\Traits\AuthManagerTrait;
@ -21,5 +22,4 @@ class RbacItemsValidator extends Validator
} }
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Validator; namespace Da\User\Validator;
use ReflectionClass; use ReflectionClass;

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Validator; namespace Da\User\Validator;
use Da\User\Contracts\ValidatorInterface; use Da\User\Contracts\ValidatorInterface;
@ -16,5 +17,4 @@ class TimeZoneValidator implements ValidatorInterface
{ {
return in_array($this->timezone, timezone_identifiers_list()); return in_array($this->timezone, timezone_identifiers_list());
} }
} }

View File

@ -16,7 +16,7 @@ class AssignmentsWidget extends Widget
use ContainerTrait; use ContainerTrait;
/** /**
* @var integer ID of the user to whom auth items will be assigned. * @var int ID of the user to whom auth items will be assigned
*/ */
public $userId; public $userId;
/** /**
@ -25,7 +25,8 @@ class AssignmentsWidget extends Widget
public $params = []; public $params = [];
/** /**
* @inheritdoc * {@inheritdoc}
*
* @throws InvalidConfigException * @throws InvalidConfigException
*/ */
public function init() public function init()
@ -37,7 +38,7 @@ class AssignmentsWidget extends Widget
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function run() public function run()
{ {
@ -49,12 +50,12 @@ class AssignmentsWidget extends Widget
return $this->render('/widgets/assignments/form', [ return $this->render('/widgets/assignments/form', [
'model' => $model, 'model' => $model,
'availableItems' => $this->getAvailableItems() 'availableItems' => $this->getAvailableItems(),
]); ]);
} }
/** /**
* Returns all available auth items to be attached to the user * Returns all available auth items to be attached to the user.
* *
* @return array * @return array
*/ */

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Da\User\Widget;
namespace Da\User\Widget;
use Yii; use Yii;
use yii\authclient\ClientInterface; use yii\authclient\ClientInterface;
@ -17,7 +17,7 @@ class ConnectWidget extends AuthChoice
public $accounts; public $accounts;
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function init() public function init()
{ {
@ -30,7 +30,7 @@ class ConnectWidget extends AuthChoice
} }
/** /**
* @inheritdoc * {@inheritdoc}
*/ */
public function createClientUrl($provider) public function createClientUrl($provider)
{ {

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Da\User\Widget; namespace Da\User\Widget;
use Da\User\Form\LoginForm; use Da\User\Form\LoginForm;
@ -14,7 +15,7 @@ class LoginWidget extends Widget
return $this->render( return $this->render(
'/widgets/login', '/widgets/login',
[ [
'model' => Yii::createObject(LoginForm::class) 'model' => Yii::createObject(LoginForm::class),
] ]
); );
} }

View File

@ -40,7 +40,7 @@ return [
'.gitignore', '.gitignore',
'.gitkeep', '.gitkeep',
'.hgignore', '.hgignore',
'.hgkeep' '.hgkeep',
], ],
'format' => 'php', 'format' => 'php',
]; ];

View File

@ -3,7 +3,7 @@
use yii\bootstrap\ActiveForm; use yii\bootstrap\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
/** /*
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\User $user * @var \Da\User\Model\User $user
*/ */

View File

@ -2,7 +2,7 @@
use Da\User\Widget\AssignmentsWidget; use Da\User\Widget\AssignmentsWidget;
/** /*
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\User $user * @var \Da\User\Model\User $user
* @var string[] $params * @var string[] $params

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @var yii\web\View $this * @var yii\web\View
* @var \Da\User\Model\User $user * @var \Da\User\Model\User $user
*/ */
?> ?>

Some files were not shown because too many files have changed in this diff Show More