mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 07:30:18 +05:30
Фиксы после инспекции кода новым инспектором в PHPStorm
В некоторых формах отключена валидация при сохранении модели аккаунта
This commit is contained in:
parent
7ec87e0602
commit
3b56f3c418
@ -17,7 +17,7 @@ class ConfirmEmailForm extends KeyConfirmationForm {
|
||||
}
|
||||
|
||||
$confirmModel = $this->getActivationCodeModel();
|
||||
if ($confirmModel->type != EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION) {
|
||||
if ($confirmModel->type !== EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION) {
|
||||
$confirmModel->delete();
|
||||
// TODO: вот где-то здесь нужно ещё попутно сгенерировать соответствующую ошибку
|
||||
return false;
|
||||
@ -31,7 +31,7 @@ class ConfirmEmailForm extends KeyConfirmationForm {
|
||||
throw new ErrorException('Unable remove activation key.');
|
||||
}
|
||||
|
||||
if (!$account->save()) {
|
||||
if (!$account->save(false)) {
|
||||
throw new ErrorException('Unable activate user account.');
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class ChangePasswordForm extends ApiForm {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$account->save()) {
|
||||
if (!$account->save(false)) {
|
||||
throw new ErrorException('Cannot save user model');
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ApiController extends Controller {
|
||||
// ник пользователь не сменил его на нечто иное
|
||||
$account = 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;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ class UserFriendlyRandomKey {
|
||||
$numChars = strlen($chars);
|
||||
$key = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$key .= substr($chars, rand(1, $numChars) - 1, 1);
|
||||
$key .= $chars[random_int(0, $numChars - 1)];
|
||||
}
|
||||
|
||||
return $key;
|
||||
|
@ -54,7 +54,7 @@ class AuthCodeStorage extends AbstractStorage implements AuthCodeInterface {
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getScopes(OriginalAuthCodeEntity $token) {
|
||||
$result = (new Set($this->dataTable, $token->getId(), 'scopes'));
|
||||
$result = new Set($this->dataTable, $token->getId(), 'scopes');
|
||||
$response = [];
|
||||
foreach ($result as $scope) {
|
||||
// TODO: нужно проверить все выданные скоупы на их существование
|
||||
|
@ -2,10 +2,9 @@
|
||||
namespace common\components\oauth\Util\KeyAlgorithm;
|
||||
|
||||
use League\OAuth2\Server\Util\KeyAlgorithm\DefaultAlgorithm;
|
||||
use League\OAuth2\Server\Util\KeyAlgorithm\KeyAlgorithmInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UuidAlgorithm extends DefaultAlgorithm implements KeyAlgorithmInterface {
|
||||
class UuidAlgorithm extends DefaultAlgorithm {
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
@ -2,7 +2,6 @@
|
||||
namespace common\helpers;
|
||||
|
||||
use common\components\RabbitMQ\Helper;
|
||||
use Yii;
|
||||
|
||||
class Amqp extends Helper {
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?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->beginBody() ?>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@
|
||||
namespace common\models;
|
||||
|
||||
use common\components\redis\Set;
|
||||
use Yii;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
@ -38,7 +37,7 @@ class OauthSession extends ActiveRecord {
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -2,6 +2,8 @@
|
||||
namespace common\models;
|
||||
|
||||
use common\components\SkinSystem\Api as SkinSystemApi;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
|
||||
class Textures {
|
||||
|
||||
@ -38,7 +40,7 @@ class Textures {
|
||||
|
||||
public function getTexturesValue($encrypted = true) {
|
||||
$array = [
|
||||
'timestamp' => time() + 60 * 60 * 24 * 2,
|
||||
'timestamp' => (new DateTime())->add(new DateInterval('P2D'))->getTimestamp(),
|
||||
'profileId' => str_replace('-', '', $this->account->uuid),
|
||||
'profileName' => $this->account->username,
|
||||
'textures' => $this->getTextures(),
|
||||
@ -51,7 +53,7 @@ class Textures {
|
||||
if (!$encrypted) {
|
||||
return $array;
|
||||
} else {
|
||||
return $this->encrypt($array);
|
||||
return static::encrypt($array);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user