Close #109 provide better error classes + phpdoc fixes
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
- Enh #100: Added pt-BR translation (gugoan)
|
- Enh #100: Added pt-BR translation (gugoan)
|
||||||
- Enh #105: Consolidate 2fa messages (maxxer)
|
- Enh #105: Consolidate 2fa messages (maxxer)
|
||||||
- Fix #108: Use main logger app (tonydspaniard)
|
- Fix #108: Use main logger app (tonydspaniard)
|
||||||
|
- Enh #109: Make use of better classes names (tonydspaniard)
|
||||||
|
|
||||||
## 1.1.0 - October 22, 2017
|
## 1.1.0 - October 22, 2017
|
||||||
- Enh #91: Documentation for Mail events (kartik-v)
|
- Enh #91: Documentation for Mail events (kartik-v)
|
||||||
|
|||||||
@ -33,6 +33,8 @@ class Bootstrap implements BootstrapInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function bootstrap($app)
|
public function bootstrap($app)
|
||||||
{
|
{
|
||||||
@ -279,6 +281,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
*
|
*
|
||||||
* @param array $userClassMap user configuration on the module
|
* @param array $userClassMap user configuration on the module
|
||||||
*
|
*
|
||||||
|
* @throws Exception
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function buildClassMap(array $userClassMap)
|
protected function buildClassMap(array $userClassMap)
|
||||||
@ -352,7 +355,7 @@ class Bootstrap implements BootstrapInterface
|
|||||||
protected function getRoute(array $routes, $name)
|
protected function getRoute(array $routes, $name)
|
||||||
{
|
{
|
||||||
foreach ($routes as $route => $names) {
|
foreach ($routes as $route => $names) {
|
||||||
if (in_array($name, $names)) {
|
if (in_array($name, $names, false)) {
|
||||||
return $route;
|
return $route;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,8 @@ class PermissionController extends AbstractAuthItemController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
protected function getItem($name)
|
protected function getItem($name)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,6 +24,8 @@ use Da\User\Service\ResetPasswordService;
|
|||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Validator\AjaxRequestModelValidator;
|
use Da\User\Validator\AjaxRequestModelValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
@ -74,6 +76,8 @@ class RecoveryController extends Controller
|
|||||||
* Displays / handles user password recovery request.
|
* Displays / handles user password recovery request.
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
|
* @throws InvalidConfigException
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -118,6 +122,8 @@ class RecoveryController extends Controller
|
|||||||
* @param $code
|
* @param $code
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
|
* @throws InvalidConfigException
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -35,6 +35,8 @@ class RoleController extends AbstractAuthItemController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
protected function getItem($name)
|
protected function getItem($name)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,6 +21,8 @@ use Da\User\Service\SocialNetworkAuthenticateService;
|
|||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\AuthAction;
|
use yii\authclient\AuthAction;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
@ -102,6 +104,8 @@ class SecurityController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Controller action responsible for handling login page and actions.
|
* Controller action responsible for handling login page and actions.
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return array|string|Response
|
* @return array|string|Response
|
||||||
*/
|
*/
|
||||||
public function actionLogin()
|
public function actionLogin()
|
||||||
|
|||||||
@ -179,7 +179,7 @@ class SettingsController extends Controller
|
|||||||
{
|
{
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
if ($user === null || $this->module->emailChangeStrategy == MailChangeStrategyInterface::TYPE_INSECURE) {
|
if ($user === null || MailChangeStrategyInterface::TYPE_INSECURE === $this->module->emailChangeStrategy) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
$event = $this->make(UserEvent::class, [$user]);
|
$event = $this->make(UserEvent::class, [$user]);
|
||||||
@ -210,7 +210,7 @@ class SettingsController extends Controller
|
|||||||
if ($account === null) {
|
if ($account === null) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
if ($account->user_id != Yii::$app->user->id) {
|
if ($account->user_id !== Yii::$app->user->id) {
|
||||||
throw new ForbiddenHttpException();
|
throw new ForbiddenHttpException();
|
||||||
}
|
}
|
||||||
$event = $this->make(SocialNetworkConnectEvent::class, [Yii::$app->user->identity, $account]);
|
$event = $this->make(SocialNetworkConnectEvent::class, [Yii::$app->user->identity, $account]);
|
||||||
|
|||||||
@ -18,6 +18,7 @@ use Da\User\Strategy\InsecureEmailChangeStrategy;
|
|||||||
use Da\User\Strategy\SecureEmailChangeStrategy;
|
use Da\User\Strategy\SecureEmailChangeStrategy;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
|
|
||||||
class EmailChangeStrategyFactory
|
class EmailChangeStrategyFactory
|
||||||
{
|
{
|
||||||
@ -41,7 +42,7 @@ class EmailChangeStrategyFactory
|
|||||||
return Yii::$container->get(static::$map[$strategy], [$form]);
|
return Yii::$container->get(static::$map[$strategy], [$form]);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('Unknown strategy type');
|
throw new InvalidParamException('Unknown strategy type');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -25,6 +25,7 @@ class MailFactory
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param bool $showPassword
|
* @param bool $showPassword
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return MailService
|
* @return MailService
|
||||||
*/
|
*/
|
||||||
public static function makeWelcomeMailerService(User $user, $showPassword = false)
|
public static function makeWelcomeMailerService(User $user, $showPassword = false)
|
||||||
@ -48,6 +49,7 @@ class MailFactory
|
|||||||
* @param string $email
|
* @param string $email
|
||||||
* @param Token $token
|
* @param Token $token
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return MailService
|
* @return MailService
|
||||||
*/
|
*/
|
||||||
public static function makeRecoveryMailerService($email, Token $token = null)
|
public static function makeRecoveryMailerService($email, Token $token = null)
|
||||||
@ -69,6 +71,7 @@ class MailFactory
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Token|null $token
|
* @param Token|null $token
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return MailService
|
* @return MailService
|
||||||
*/
|
*/
|
||||||
public static function makeConfirmationMailerService(User $user, Token $token = null)
|
public static function makeConfirmationMailerService(User $user, Token $token = null)
|
||||||
@ -90,6 +93,7 @@ class MailFactory
|
|||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Token $token
|
* @param Token $token
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return MailService
|
* @return MailService
|
||||||
*/
|
*/
|
||||||
public static function makeReconfirmationMailerService(User $user, Token $token)
|
public static function makeReconfirmationMailerService(User $user, Token $token)
|
||||||
|
|||||||
@ -13,12 +13,14 @@ namespace Da\User\Factory;
|
|||||||
|
|
||||||
use Da\User\Model\Token;
|
use Da\User\Model\Token;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
class TokenFactory
|
class TokenFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param $userId
|
* @param $userId
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return Token
|
* @return Token
|
||||||
*/
|
*/
|
||||||
public static function makeConfirmationToken($userId)
|
public static function makeConfirmationToken($userId)
|
||||||
@ -47,6 +49,7 @@ class TokenFactory
|
|||||||
/**
|
/**
|
||||||
* @param $userId
|
* @param $userId
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return Token
|
* @return Token
|
||||||
*/
|
*/
|
||||||
public static function makeConfirmOldMailToken($userId)
|
public static function makeConfirmOldMailToken($userId)
|
||||||
@ -61,6 +64,7 @@ class TokenFactory
|
|||||||
/**
|
/**
|
||||||
* @param $userId
|
* @param $userId
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return Token
|
* @return Token
|
||||||
*/
|
*/
|
||||||
public static function makeRecoveryToken($userId)
|
public static function makeRecoveryToken($userId)
|
||||||
@ -76,7 +80,8 @@ class TokenFactory
|
|||||||
* @param $userId
|
* @param $userId
|
||||||
* @param $type
|
* @param $type
|
||||||
*
|
*
|
||||||
* @return Token
|
* @throws InvalidConfigException
|
||||||
|
* @return Token|\object
|
||||||
*/
|
*/
|
||||||
protected static function make($userId, $type)
|
protected static function make($userId, $type)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,6 +18,7 @@ use Da\User\Query\UserQuery;
|
|||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\TwoFactorCodeValidator;
|
use Da\User\Validator\TwoFactorCodeValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|
||||||
class LoginForm extends Model
|
class LoginForm extends Model
|
||||||
@ -140,6 +141,7 @@ class LoginForm extends Model
|
|||||||
/**
|
/**
|
||||||
* Validates form and logs the user in.
|
* Validates form and logs the user in.
|
||||||
*
|
*
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return bool whether the user is logged in successfully
|
* @return bool whether the user is logged in successfully
|
||||||
*/
|
*/
|
||||||
public function login()
|
public function login()
|
||||||
|
|||||||
@ -18,7 +18,9 @@ use Da\User\Traits\ContainerAwareTrait;
|
|||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
class SettingsForm extends Model
|
class SettingsForm extends Model
|
||||||
{
|
{
|
||||||
@ -49,19 +51,28 @@ class SettingsForm extends Model
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SettingsForm constructor.
|
||||||
|
*
|
||||||
|
* @param SecurityHelper $securityHelper
|
||||||
|
* @param array $config
|
||||||
|
*/
|
||||||
public function __construct(SecurityHelper $securityHelper, array $config = [])
|
public function __construct(SecurityHelper $securityHelper, array $config = [])
|
||||||
{
|
{
|
||||||
$this->securityHelper = $securityHelper;
|
$this->securityHelper = $securityHelper;
|
||||||
$config = [
|
$config = ArrayHelper::merge(
|
||||||
'username' => $this->getUser()->username,
|
[
|
||||||
'email' => $this->getUser()->unconfirmed_email? : $this->getUser()->email
|
'username' => $this->getUser()->username,
|
||||||
];
|
'email' => $this->getUser()->unconfirmed_email ?: $this->getUser()->email
|
||||||
|
],
|
||||||
|
$config
|
||||||
|
);
|
||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws InvalidConfigException
|
* @throws InvalidConfigException
|
||||||
* @throws \Exception
|
* @throws InvalidParamException
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Da\User\Helper;
|
namespace Da\User\Helper;
|
||||||
|
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
|
|
||||||
class ClassMapHelper
|
class ClassMapHelper
|
||||||
{
|
{
|
||||||
protected $map = [];
|
protected $map = [];
|
||||||
@ -37,7 +39,7 @@ class ClassMapHelper
|
|||||||
/**
|
/**
|
||||||
* @param $key
|
* @param $key
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws InvalidParamException
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -46,6 +48,6 @@ class ClassMapHelper
|
|||||||
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 InvalidParamException('Unknown model map key: ' . $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,7 +108,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],
|
||||||
|
|||||||
@ -20,6 +20,7 @@ use DateTime;
|
|||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\db\ActiveRecord;
|
use yii\db\ActiveRecord;
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ class Profile extends ActiveRecord
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @throws InvalidParamException
|
* @throws InvalidParamException
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function beforeSave($insert)
|
public function beforeSave($insert)
|
||||||
{
|
{
|
||||||
@ -67,6 +69,8 @@ class Profile extends ActiveRecord
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
@ -125,6 +129,8 @@ class Profile extends ActiveRecord
|
|||||||
* Set the User's timezone.
|
* Set the User's timezone.
|
||||||
*
|
*
|
||||||
* @param DateTimeZone $timezone
|
* @param DateTimeZone $timezone
|
||||||
|
*
|
||||||
|
* @throws InvalidParamException
|
||||||
*/
|
*/
|
||||||
public function setTimeZone(DateTimeZone $timezone)
|
public function setTimeZone(DateTimeZone $timezone)
|
||||||
{
|
{
|
||||||
@ -144,6 +150,7 @@ class Profile extends ActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return \yii\db\ActiveQuery
|
* @return \yii\db\ActiveQuery
|
||||||
*/
|
*/
|
||||||
public function getUser()
|
public function getUser()
|
||||||
@ -154,6 +161,7 @@ class Profile extends ActiveRecord
|
|||||||
/**
|
/**
|
||||||
* @param int $size
|
* @param int $size
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAvatarUrl($size = 200)
|
public function getAvatarUrl($size = 200)
|
||||||
|
|||||||
@ -15,6 +15,8 @@ use Da\User\Query\SocialNetworkAccountQuery;
|
|||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\Exception;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\db\ActiveRecord;
|
use yii\db\ActiveRecord;
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ class SocialNetworkAccount extends ActiveRecord
|
|||||||
*/
|
*/
|
||||||
public function getIsConnected()
|
public function getIsConnected()
|
||||||
{
|
{
|
||||||
return $this->user_id != null;
|
return null !== $this->user_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,6 +73,8 @@ class SocialNetworkAccount extends ActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return string the connection url
|
* @return string the connection url
|
||||||
*/
|
*/
|
||||||
public function getConnectionUrl()
|
public function getConnectionUrl()
|
||||||
|
|||||||
@ -16,6 +16,8 @@ use Da\User\Query\TokenQuery;
|
|||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\db\ActiveRecord;
|
use yii\db\ActiveRecord;
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
|
|
||||||
@ -49,6 +51,9 @@ class Token extends ActiveRecord
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws InvalidParamException
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function beforeSave($insert)
|
public function beforeSave($insert)
|
||||||
{
|
{
|
||||||
@ -86,6 +91,7 @@ class Token extends ActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUrl()
|
public function getUrl()
|
||||||
@ -94,16 +100,17 @@ class Token extends ActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
* @return bool Whether token has expired
|
* @return bool Whether token has expired
|
||||||
*/
|
*/
|
||||||
public function getIsExpired()
|
public function getIsExpired()
|
||||||
{
|
{
|
||||||
if ($this->type == static::TYPE_RECOVERY) {
|
if ($this->type === static::TYPE_RECOVERY) {
|
||||||
$expirationTime = $this->getModule()->tokenRecoveryLifespan;
|
$expirationTime = $this->getModule()->tokenRecoveryLifespan;
|
||||||
} elseif ($this->type >= static::TYPE_CONFIRMATION && $this->type <= static::TYPE_CONFIRM_OLD_EMAIL) {
|
} elseif ($this->type >= static::TYPE_CONFIRMATION && $this->type <= static::TYPE_CONFIRM_OLD_EMAIL) {
|
||||||
$expirationTime = $this->getModule()->tokenConfirmationLifespan;
|
$expirationTime = $this->getModule()->tokenConfirmationLifespan;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException('Unknown Token type.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($this->created_at + $expirationTime) < time();
|
return ($this->created_at + $expirationTime) < time();
|
||||||
|
|||||||
@ -16,6 +16,8 @@ use Da\User\Query\UserQuery;
|
|||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\Exception;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\NotSupportedException;
|
use yii\base\NotSupportedException;
|
||||||
use yii\behaviors\TimestampBehavior;
|
use yii\behaviors\TimestampBehavior;
|
||||||
@ -74,6 +76,8 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @throws InvalidParamException
|
* @throws InvalidParamException
|
||||||
|
* @throws InvalidConfigException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function beforeSave($insert)
|
public function beforeSave($insert)
|
||||||
{
|
{
|
||||||
@ -98,6 +102,8 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function afterSave($insert, $changedAttributes)
|
public function afterSave($insert, $changedAttributes)
|
||||||
{
|
{
|
||||||
@ -242,6 +248,7 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return bool whether the user is an admin or not
|
* @return bool whether the user is an admin or not
|
||||||
*/
|
*/
|
||||||
public function getIsAdmin()
|
public function getIsAdmin()
|
||||||
@ -271,6 +278,8 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws InvalidConfigException
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return \yii\db\ActiveQuery
|
* @return \yii\db\ActiveQuery
|
||||||
*/
|
*/
|
||||||
public function getProfile()
|
public function getProfile()
|
||||||
@ -285,7 +294,7 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
*/
|
*/
|
||||||
public function getSocialNetworkAccounts()
|
public function getSocialNetworkAccounts()
|
||||||
{
|
{
|
||||||
if ($this->connectedAccounts == null) {
|
if (null === $this->connectedAccounts) {
|
||||||
/** @var SocialNetworkAccount[] $accounts */
|
/** @var SocialNetworkAccount[] $accounts */
|
||||||
$accounts = $this->hasMany(
|
$accounts = $this->hasMany(
|
||||||
$this->getClassMap()
|
$this->getClassMap()
|
||||||
|
|||||||
@ -13,6 +13,8 @@ namespace Da\User\Search;
|
|||||||
|
|
||||||
use Da\User\Model\Rule;
|
use Da\User\Model\Rule;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use yii\db\Query;
|
use yii\db\Query;
|
||||||
@ -47,6 +49,8 @@ class RuleSearch extends Rule
|
|||||||
/**
|
/**
|
||||||
* @param array $params
|
* @param array $params
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return ActiveDataProvider
|
* @return ActiveDataProvider
|
||||||
*/
|
*/
|
||||||
public function search(array $params = [])
|
public function search(array $params = [])
|
||||||
|
|||||||
@ -13,6 +13,7 @@ namespace Da\User\Search;
|
|||||||
|
|
||||||
use Da\User\Query\UserQuery;
|
use Da\User\Query\UserQuery;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ class UserSearch extends Model
|
|||||||
/**
|
/**
|
||||||
* @param $params
|
* @param $params
|
||||||
*
|
*
|
||||||
|
* @throws InvalidParamException
|
||||||
* @return ActiveDataProvider
|
* @return ActiveDataProvider
|
||||||
*/
|
*/
|
||||||
public function search($params)
|
public function search($params)
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use Da\User\Model\User;
|
|||||||
use Da\User\Service\MailService;
|
use Da\User\Service\MailService;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property MailService $mailService
|
* @property MailService $mailService
|
||||||
@ -29,6 +30,7 @@ trait MailAwareTrait
|
|||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function sendMail(User $user)
|
protected function sendMail(User $user)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ namespace Da\User\Validator;
|
|||||||
|
|
||||||
use Da\User\Component\ReCaptchaComponent;
|
use Da\User\Component\ReCaptchaComponent;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
use yii\validators\Validator;
|
use yii\validators\Validator;
|
||||||
|
|
||||||
class ReCaptchaValidator extends Validator
|
class ReCaptchaValidator extends Validator
|
||||||
@ -52,6 +53,8 @@ class ReCaptchaValidator extends Validator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
protected function validateValue($value)
|
protected function validateValue($value)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,6 +24,6 @@ class TimeZoneValidator implements ValidatorInterface
|
|||||||
|
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
return in_array($this->timezone, timezone_identifiers_list());
|
return in_array($this->timezone, timezone_identifiers_list(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,7 @@ class AssignmentsWidget extends Widget
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @throws InvalidParamException
|
* @throws InvalidParamException
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,6 +15,7 @@ use Yii;
|
|||||||
use yii\authclient\ClientInterface;
|
use yii\authclient\ClientInterface;
|
||||||
use yii\authclient\widgets\AuthChoice;
|
use yii\authclient\widgets\AuthChoice;
|
||||||
use yii\authclient\widgets\AuthChoiceAsset;
|
use yii\authclient\widgets\AuthChoiceAsset;
|
||||||
|
use yii\base\InvalidParamException;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\helpers\Url;
|
use yii\helpers\Url;
|
||||||
|
|
||||||
@ -40,6 +41,8 @@ class ConnectWidget extends AuthChoice
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws InvalidParamException
|
||||||
*/
|
*/
|
||||||
public function createClientUrl($provider)
|
public function createClientUrl($provider)
|
||||||
{
|
{
|
||||||
@ -59,6 +62,6 @@ class ConnectWidget extends AuthChoice
|
|||||||
*/
|
*/
|
||||||
public function isConnected(ClientInterface $provider)
|
public function isConnected(ClientInterface $provider)
|
||||||
{
|
{
|
||||||
return $this->accounts != null && isset($this->accounts[$provider->getId()]);
|
return null !== $this->accounts && isset($this->accounts[$provider->getId()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,8 @@ class ReCaptchaWidget extends InputWidget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
*
|
||||||
|
* @throws InvalidConfigException
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
@ -78,6 +80,7 @@ class ReCaptchaWidget extends InputWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws InvalidConfigException
|
||||||
* @return array the google recaptcha options.
|
* @return array the google recaptcha options.
|
||||||
*/
|
*/
|
||||||
protected function getCaptchaOptions()
|
protected function getCaptchaOptions()
|
||||||
@ -156,7 +159,7 @@ class ReCaptchaWidget extends InputWidget
|
|||||||
'pt-PT'
|
'pt-PT'
|
||||||
];
|
];
|
||||||
|
|
||||||
return in_array($language, $except)
|
return in_array($language, $except, false)
|
||||||
? $language
|
? $language
|
||||||
: substr($language, 0, strpos($language, '-'));
|
: substr($language, 0, strpos($language, '-'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user