documentation update + code fixes

This commit is contained in:
Antonio Ramirez
2017-06-11 23:25:51 +02:00
parent 4dedf111a1
commit 7344ad31df
91 changed files with 1699 additions and 827 deletions

View File

@ -81,7 +81,6 @@ class AuthItemEditionService implements ServiceInterface
$childrenNames = array_keys($children);
if (is_array($this->model->children)) {
// remove those not linked anymore
foreach (array_diff($childrenNames, $this->model->children) as $item) {
if (!$this->getAuthManager()->removeChild($this->model->item, $children[$item])) {

View File

@ -41,45 +41,45 @@ class EmailChangeService implements ServiceInterface
Yii::$app->session->setFlash('danger', Yii::t('usuario', 'Your confirmation token is invalid or expired'));
return false;
} else {
$token->delete();
if (empty($this->model->unconfirmed_email)) {
Yii::$app->session->setFlash('danger', Yii::t('usuario', 'An error occurred processing your request'));
} elseif ($this->userQuery->whereEmail($this->model->unconfirmed_email)->exists() === false) {
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_SECURE) {
if ($token->type === Token::TYPE_CONFIRM_NEW_EMAIL) {
$this->model->flags |= User::NEW_EMAIL_CONFIRMED;
Yii::$app->session->setFlash(
'success',
Yii::t(
'usuario',
'Awesome, almost there. '.
'Now you need to click the confirmation link sent to your old email address.'
)
);
} elseif ($token->type === Token::TYPE_CONFIRM_OLD_EMAIL) {
$this->model->flags |= User::OLD_EMAIL_CONFIRMED;
Yii::$app->session->setFlash(
'success',
Yii::t(
'usuario',
'Awesome, almost there. '.
'Now you need to click the confirmation link sent to your new email address.'
)
);
}
}
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_DEFAULT
|| ($this->model->flags & User::NEW_EMAIL_CONFIRMED & $this->model->flags & User::OLD_EMAIL_CONFIRMED)
) {
$this->model->email = $this->model->unconfirmed_email;
$this->model->unconfirmed_email = null;
Yii::$app->session->setFlash('success', Yii::t('usuario', 'Your email address has been changed'));
}
return $this->model->save(false);
}
}
$token->delete();
if (empty($this->model->unconfirmed_email)) {
Yii::$app->session->setFlash('danger', Yii::t('usuario', 'An error occurred processing your request'));
} elseif ($this->userQuery->whereEmail($this->model->unconfirmed_email)->exists() === false) {
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_SECURE) {
if ($token->type === Token::TYPE_CONFIRM_NEW_EMAIL) {
$this->model->flags |= User::NEW_EMAIL_CONFIRMED;
Yii::$app->session->setFlash(
'success',
Yii::t(
'usuario',
'Awesome, almost there. ' .
'Now you need to click the confirmation link sent to your old email address.'
)
);
} elseif ($token->type === Token::TYPE_CONFIRM_OLD_EMAIL) {
$this->model->flags |= User::OLD_EMAIL_CONFIRMED;
Yii::$app->session->setFlash(
'success',
Yii::t(
'usuario',
'Awesome, almost there. ' .
'Now you need to click the confirmation link sent to your new email address.'
)
);
}
}
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_DEFAULT
|| ($this->model->flags & User::NEW_EMAIL_CONFIRMED & $this->model->flags & User::OLD_EMAIL_CONFIRMED)
) {
$this->model->email = $this->model->unconfirmed_email;
$this->model->unconfirmed_email = null;
Yii::$app->session->setFlash('success', Yii::t('usuario', 'Your email address has been changed'));
}
return $this->model->save(false);
}
return false;
}

View File

@ -20,11 +20,11 @@ class MailService implements ServiceInterface
/**
* MailService constructor.
*
* @param string $from
* @param string $to
* @param string $subject
* @param string $view
* @param array $params
* @param string $from
* @param string $to
* @param string $subject
* @param string $view
* @param array $params
* @param MailerInterface $mailer
*/
public function __construct($from, $to, $subject, $view, array $params, BaseMailer $mailer)

View File

@ -30,7 +30,7 @@ class ResetPasswordService implements ServiceInterface
public function run()
{
return $this->model && (bool) $this->model->updateAttributes(
return $this->model && (bool)$this->model->updateAttributes(
[
'password_hash' => $this->securityHelper->generatePasswordHash($this->password),
]

View File

@ -32,8 +32,8 @@ class SocialNetworkAccountConnectService implements ServiceInterface
/**
* SocialNetworkAccountUserLinkService constructor.
*
* @param SecurityController $controller
* @param AuthClientInterface $client
* @param SecurityController $controller
* @param AuthClientInterface $client
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
*/
public function __construct(
@ -62,12 +62,12 @@ class SocialNetworkAccountConnectService implements ServiceInterface
$this->controller->trigger(SocialNetworkAuthEvent::EVENT_AFTER_CONNECT, $event);
return true;
} else {
Yii::$app->session->setFlash(
'danger',
Yii::t('usuario', 'This account has already been connected to another user')
);
}
Yii::$app->session->setFlash(
'danger',
Yii::t('usuario', 'This account has already been connected to another user')
);
return false;
}

View File

@ -40,11 +40,11 @@ class UserBlockService implements ServiceInterface
{
if ($this->model->getIsBlocked()) {
$this->controller->trigger(UserEvent::EVENT_BEFORE_UNBLOCK, $this->event);
$result = (bool) $this->model->updateAttributes(['blocked_at' => null]);
$result = (bool)$this->model->updateAttributes(['blocked_at' => null]);
$this->controller->trigger(UserEvent::EVENT_AFTER_UNBLOCK, $this->event);
} else {
$this->controller->trigger(UserEvent::EVENT_BEFORE_BLOCK, $this->event);
$result = (bool) $this->model->updateAttributes(
$result = (bool)$this->model->updateAttributes(
['blocked_at' => time(), 'auth_key' => $this->securityHelper->generateRandomString()]
);
$this->controller->trigger(UserEvent::EVENT_AFTER_BLOCK, $this->event);

View File

@ -27,7 +27,7 @@ class UserConfirmationService implements ServiceInterface
public function run()
{
$this->model->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION);
if ((bool) $this->model->updateAttributes(['confirmed_at' => time()])) {
if ((bool)$this->model->updateAttributes(['confirmed_at' => time()])) {
$this->model->trigger(UserEvent::EVENT_AFTER_CONFIRMATION);
return true;

View File

@ -15,8 +15,8 @@ use Da\User\Contracts\ServiceInterface;
use Da\User\Event\UserEvent;
use Da\User\Helper\SecurityHelper;
use Da\User\Model\User;
use yii\base\InvalidCallException;
use Exception;
use yii\base\InvalidCallException;
use yii\log\Logger;
class UserCreateService implements ServiceInterface