Фиксы после инспекции кода новым инспектором в PHPStorm

В некоторых формах отключена валидация при сохранении модели аккаунта
This commit is contained in:
ErickSkrauch 2016-11-01 19:36:39 +03:00
parent 7ec87e0602
commit 3b56f3c418
11 changed files with 17 additions and 18 deletions

View File

@ -17,7 +17,7 @@ class ConfirmEmailForm extends KeyConfirmationForm {
} }
$confirmModel = $this->getActivationCodeModel(); $confirmModel = $this->getActivationCodeModel();
if ($confirmModel->type != EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION) { if ($confirmModel->type !== EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION) {
$confirmModel->delete(); $confirmModel->delete();
// TODO: вот где-то здесь нужно ещё попутно сгенерировать соответствующую ошибку // TODO: вот где-то здесь нужно ещё попутно сгенерировать соответствующую ошибку
return false; return false;
@ -31,7 +31,7 @@ class ConfirmEmailForm extends KeyConfirmationForm {
throw new ErrorException('Unable remove activation key.'); throw new ErrorException('Unable remove activation key.');
} }
if (!$account->save()) { if (!$account->save(false)) {
throw new ErrorException('Unable activate user account.'); throw new ErrorException('Unable activate user account.');
} }

View File

@ -77,7 +77,7 @@ class ChangePasswordForm extends ApiForm {
} }
} }
if (!$account->save()) { if (!$account->save(false)) {
throw new ErrorException('Cannot save user model'); throw new ErrorException('Cannot save user model');
} }

View File

@ -32,7 +32,7 @@ class ApiController extends Controller {
// ник пользователь не сменил его на нечто иное // ник пользователь не сменил его на нечто иное
$account = null; $account = null;
if ($record !== null) { if ($record !== null) {
if ($record->findNext($at) !== null || $record->account->username === $record->username) { if ($record->account->username === $record->username || $record->findNext($at) !== null) {
$account = $record->account; $account = $record->account;
} }
} }

View File

@ -9,7 +9,7 @@ class UserFriendlyRandomKey {
$numChars = strlen($chars); $numChars = strlen($chars);
$key = ''; $key = '';
for ($i = 0; $i < $length; $i++) { for ($i = 0; $i < $length; $i++) {
$key .= substr($chars, rand(1, $numChars) - 1, 1); $key .= $chars[random_int(0, $numChars - 1)];
} }
return $key; return $key;

View File

@ -54,7 +54,7 @@ class AuthCodeStorage extends AbstractStorage implements AuthCodeInterface {
* @inheritdoc * @inheritdoc
*/ */
public function getScopes(OriginalAuthCodeEntity $token) { public function getScopes(OriginalAuthCodeEntity $token) {
$result = (new Set($this->dataTable, $token->getId(), 'scopes')); $result = new Set($this->dataTable, $token->getId(), 'scopes');
$response = []; $response = [];
foreach ($result as $scope) { foreach ($result as $scope) {
// TODO: нужно проверить все выданные скоупы на их существование // TODO: нужно проверить все выданные скоупы на их существование

View File

@ -2,10 +2,9 @@
namespace common\components\oauth\Util\KeyAlgorithm; namespace common\components\oauth\Util\KeyAlgorithm;
use League\OAuth2\Server\Util\KeyAlgorithm\DefaultAlgorithm; use League\OAuth2\Server\Util\KeyAlgorithm\DefaultAlgorithm;
use League\OAuth2\Server\Util\KeyAlgorithm\KeyAlgorithmInterface;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
class UuidAlgorithm extends DefaultAlgorithm implements KeyAlgorithmInterface { class UuidAlgorithm extends DefaultAlgorithm {
/** /**
* @inheritdoc * @inheritdoc

View File

@ -2,7 +2,6 @@
namespace common\helpers; namespace common\helpers;
use common\components\RabbitMQ\Helper; use common\components\RabbitMQ\Helper;
use Yii;
class Amqp extends Helper { class Amqp extends Helper {

View File

@ -1,9 +1,10 @@
<?php <?php
use yii\helpers\Html; /**
* @var $this \yii\web\View view component instance
* @var $message \yii\mail\MessageInterface the message being composed
* @var $content string main view render result
*/
/* @var $this \yii\web\View view component instance */
/* @var $message \yii\mail\MessageInterface the message being composed */
/* @var $content string main view render result */
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<?php $this->beginBody() ?> <?php $this->beginBody() ?>

View File

@ -1,7 +1,6 @@
<?php <?php
namespace common\models; namespace common\models;
use Yii;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
/** /**

View File

@ -2,7 +2,6 @@
namespace common\models; namespace common\models;
use common\components\redis\Set; use common\components\redis\Set;
use Yii;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
/** /**
@ -38,7 +37,7 @@ class OauthSession extends ActiveRecord {
} }
public function getScopes() { public function getScopes() {
return new Set($this->getDb()->getSchema()->getRawTableName($this->tableName()), $this->id, 'scopes'); return new Set(static::getDb()->getSchema()->getRawTableName(static::tableName()), $this->id, 'scopes');
} }
public function beforeDelete() { public function beforeDelete() {

View File

@ -2,6 +2,8 @@
namespace common\models; namespace common\models;
use common\components\SkinSystem\Api as SkinSystemApi; use common\components\SkinSystem\Api as SkinSystemApi;
use DateInterval;
use DateTime;
class Textures { class Textures {
@ -38,7 +40,7 @@ class Textures {
public function getTexturesValue($encrypted = true) { public function getTexturesValue($encrypted = true) {
$array = [ $array = [
'timestamp' => time() + 60 * 60 * 24 * 2, 'timestamp' => (new DateTime())->add(new DateInterval('P2D'))->getTimestamp(),
'profileId' => str_replace('-', '', $this->account->uuid), 'profileId' => str_replace('-', '', $this->account->uuid),
'profileName' => $this->account->username, 'profileName' => $this->account->username,
'textures' => $this->getTextures(), 'textures' => $this->getTextures(),
@ -51,7 +53,7 @@ class Textures {
if (!$encrypted) { if (!$encrypted) {
return $array; return $array;
} else { } else {
return $this->encrypt($array); return static::encrypt($array);
} }
} }