// Аккаунт на сервере найден
if ($account) {
if ($account['password'] == $l2->passwordEncrypt($this->getPassword())) {
// Аккаунта на сайте нет, создаю его так как на сервере он уже есть
if (!$siteAccount) {
$email = null;
$columnNames = $l2->getDb()
->getSchema()
->getTable('accounts')
->getColumnNames();
if (is_array($columnNames)) {
foreach ($columnNames as $column) {
if (strpos($column, 'mail') !== false && isset($account[$column])) {
$email = $account[$column];
}
}
}
// В таблице с аккаунтами нет поля с Email. Нет смысла регать дальше аккаунт на сайте
if (!$email) {
throw new Exception('Аккаунт не найден');
}
// Создаю аккаунт на сайте
$userModel = Users::create($login, $email, Users::STATUS_ACTIVATED, $lsId, Users::ROLE_DEFAULT);
$userModel->save(false);
$siteAccountUserId = $userModel->user_id;
}
$found = true;
}
}
// Аккаунт не найден
if (!$found) {
if ($siteAccountUserId) {
UsersAuthLogs::model()->addErrorAuth($siteAccountUserId);
}
$this->incrementBadAttempt();
$this->addError($attr, 'Неправильный Логин или Пароль.');
}
} catch (Exception $e) {
$this->addError('login', $e->getMessage());
}
}
public function passwordEncrypt($password)
{
if ($this->config('password_type') == Ls::PASSWORD_TYPE_WHIRLPOOL) {
return base64_encode(hash('whirlpool', $password, true));
} else if ($this->config('password_type') == Ls::PASSWORD_TYPE_PBKDF2WITHHMACSHA1) {
$algorithm = "sha1";
$iterations = 1000;
$salt = random_bytes(24);
$hash = hash_pbkdf2($algorithm, $password, $salt, $iterations, 24, true);
return $algorithm . ":" . $iterations . ":" . base64_encode($salt) . ":" . base64_encode($hash);
}
return base64_encode(pack('H*', sha1(utf8_encode($password))));
}
$acc_password = $account['password'];
$cur_password = $this->getPassword();
var_dump($acc_password);
var_dump($cur_password);
if ($acc_password == $l2->passwordEncrypt($cur_password)) {
// ... далее код не трогайте
array
(
'code' => 500
'type' => 'CDbException'
'errorCode' => 22001
'message' => 'CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column \'password_type\' at row 1'
'file' => '/usr/share/nginx/html/ghtweb5/framework/db/CDbCommand.php'
'line' => 358
'trace' => '#0 /usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php(1756): CDbCommand->execute()
#1 /usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php(1130): CActiveRecord->updateByPk()
#2 /usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php(811): CActiveRecord->update()
#3 /usr/share/nginx/html/ghtweb5/protected/modules/backend/controllers/LoginServersController.php(33): CActiveRecord->save()
#4 [internal function]: LoginServersController->actionForm()
#5 /usr/share/nginx/html/ghtweb5/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs()
#6 /usr/share/nginx/html/ghtweb5/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal()
#7 /usr/share/nginx/html/ghtweb5/framework/web/CController.php(308): CInlineAction->runWithParams()
#8 /usr/share/nginx/html/ghtweb5/framework/web/CController.php(286): CController->runAction()
#9 /usr/share/nginx/html/ghtweb5/framework/web/CController.php(265): CController->runActionWithFilters()
#10 /usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php(282): CController->run()
#11 /usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php(141): CWebApplication->runController()
#12 /usr/share/nginx/html/ghtweb5/framework/base/CApplication.php(185): CWebApplication->processRequest()
#13 /usr/share/nginx/html/ghtweb5/public/index.php(51): CApplication->run()
#14 {main}'
'traces' => array
(
0 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php'
'line' => 1756
'function' => 'execute'
'class' => 'CDbCommand'
'type' => '->'
)
1 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php'
'line' => 1130
'function' => 'updateByPk'
'class' => 'CActiveRecord'
'type' => '->'
)
2 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php'
'line' => 811
'function' => 'update'
'class' => 'CActiveRecord'
'type' => '->'
)
3 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/protected/modules/backend/controllers/LoginServersController.php'
'line' => 33
'function' => 'save'
'class' => 'CActiveRecord'
'type' => '->'
)
4 => array
(
'function' => 'actionForm'
'class' => 'LoginServersController'
'type' => '->'
'file' => 'unknown'
'line' => 0
)
5 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/actions/CAction.php'
'line' => 109
'function' => 'invokeArgs'
'class' => 'ReflectionMethod'
'type' => '->'
)
6 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/actions/CInlineAction.php'
'line' => 47
'function' => 'runWithParamsInternal'
'class' => 'CAction'
'type' => '->'
)
7 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CController.php'
'line' => 308
'function' => 'runWithParams'
'class' => 'CInlineAction'
'type' => '->'
)
8 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CController.php'
'line' => 286
'function' => 'runAction'
'class' => 'CController'
'type' => '->'
)
9 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CController.php'
'line' => 265
'function' => 'runActionWithFilters'
'class' => 'CController'
'type' => '->'
)
10 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php'
'line' => 282
'function' => 'run'
'class' => 'CController'
'type' => '->'
)
11 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php'
'line' => 141
'function' => 'runController'
'class' => 'CWebApplication'
'type' => '->'
)
12 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/framework/base/CApplication.php'
'line' => 185
'function' => 'processRequest'
'class' => 'CWebApplication'
'type' => '->'
)
13 => array
(
'file' => '/usr/share/nginx/html/ghtweb5/public/index.php'
'line' => 51
'function' => 'run'
'class' => 'CApplication'
'type' => '->'
)
)
)
Слишком длинный пароль. Видимо колонка в бд не рассчитывалась под такую длинную строку. Надо изменить допустимую длину колонки password_type.@ElectroMyStyle, я проводил неправильные тесты. В настройках сайта не менял тип авторизации. После вашего последнего сообщения попробовал сделать это и получил ошибку. Похоже, на не соответствии типов. Колонку password_type мне не удалось найти, чтобы увеличить количество символов.
Тестировал и с кодом @Mex-Vision и с вашим вариантом. Текст ошибки одинаковый.
Не уверен, что получится безболезненно поменять тип авторизации на сайте. Ведь, когда я менял на whirpool, мне приходилось менять тип авторизации и на сервере, и перезапускать его.
PHP:array ( 'code' => 500 'type' => 'CDbException' 'errorCode' => 22001 'message' => 'CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column \'password_type\' at row 1' 'file' => '/usr/share/nginx/html/ghtweb5/framework/db/CDbCommand.php' 'line' => 358 'trace' => '#0 /usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php(1756): CDbCommand->execute() #1 /usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php(1130): CActiveRecord->updateByPk() #2 /usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php(811): CActiveRecord->update() #3 /usr/share/nginx/html/ghtweb5/protected/modules/backend/controllers/LoginServersController.php(33): CActiveRecord->save() #4 [internal function]: LoginServersController->actionForm() #5 /usr/share/nginx/html/ghtweb5/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs() #6 /usr/share/nginx/html/ghtweb5/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal() #7 /usr/share/nginx/html/ghtweb5/framework/web/CController.php(308): CInlineAction->runWithParams() #8 /usr/share/nginx/html/ghtweb5/framework/web/CController.php(286): CController->runAction() #9 /usr/share/nginx/html/ghtweb5/framework/web/CController.php(265): CController->runActionWithFilters() #10 /usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php(282): CController->run() #11 /usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php(141): CWebApplication->runController() #12 /usr/share/nginx/html/ghtweb5/framework/base/CApplication.php(185): CWebApplication->processRequest() #13 /usr/share/nginx/html/ghtweb5/public/index.php(51): CApplication->run() #14 {main}' 'traces' => array ( 0 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php' 'line' => 1756 'function' => 'execute' 'class' => 'CDbCommand' 'type' => '->' ) 1 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php' 'line' => 1130 'function' => 'updateByPk' 'class' => 'CActiveRecord' 'type' => '->' ) 2 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/db/ar/CActiveRecord.php' 'line' => 811 'function' => 'update' 'class' => 'CActiveRecord' 'type' => '->' ) 3 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/protected/modules/backend/controllers/LoginServersController.php' 'line' => 33 'function' => 'save' 'class' => 'CActiveRecord' 'type' => '->' ) 4 => array ( 'function' => 'actionForm' 'class' => 'LoginServersController' 'type' => '->' 'file' => 'unknown' 'line' => 0 ) 5 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/actions/CAction.php' 'line' => 109 'function' => 'invokeArgs' 'class' => 'ReflectionMethod' 'type' => '->' ) 6 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/actions/CInlineAction.php' 'line' => 47 'function' => 'runWithParamsInternal' 'class' => 'CAction' 'type' => '->' ) 7 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CController.php' 'line' => 308 'function' => 'runWithParams' 'class' => 'CInlineAction' 'type' => '->' ) 8 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CController.php' 'line' => 286 'function' => 'runAction' 'class' => 'CController' 'type' => '->' ) 9 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CController.php' 'line' => 265 'function' => 'runActionWithFilters' 'class' => 'CController' 'type' => '->' ) 10 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php' 'line' => 282 'function' => 'run' 'class' => 'CController' 'type' => '->' ) 11 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/web/CWebApplication.php' 'line' => 141 'function' => 'runController' 'class' => 'CWebApplication' 'type' => '->' ) 12 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/framework/base/CApplication.php' 'line' => 185 'function' => 'processRequest' 'class' => 'CWebApplication' 'type' => '->' ) 13 => array ( 'file' => '/usr/share/nginx/html/ghtweb5/public/index.php' 'line' => 51 'function' => 'run' 'class' => 'CApplication' 'type' => '->' ) ) )
киньте файл@Mex-Vision, после смены типа шифрования и регистрации новой учётки, я не могу зайти на сайт в ЛК, но пароль подходит в ЛС. =))
Что происходит на моменте логина?Запрошенный файл.
Сделайте вывод паролей как я описал в предыдущем сообщении, чтобы понять какие данные паролей сравниваются при авторизации. Без этой информации сложно понять, что происходит и почему не проходит авторизация в ЛК на сайте. И прикрепите данные паролей в сообщенииЯ получаю сообщение об ошибке. Прилагаю скриншот. Но эта же комбинация логина и пароля подходит в ЛС.
// Аккаунт на сервере найден
if ($account) {
if ($l2->checkHash($this->getPassword(), $account['password'])) {
// Аккаунта на сайте нет, создаю его так как на сервере он уже есть
if (!$siteAccount) {
$email = null;
// Аккаунт на сервере найден
if ($account) {
/** if ($l2->checkHash($this->getPassword(), $account['password'])) { */
$acc_password = $account['password'];
$cur_password = $this->getPassword();
var_dump($acc_password);
var_dump($cur_password);
if ($acc_password == $l2->passwordEncrypt($cur_password)) {
// Аккаунта на сайте нет, создаю его так как на сервере он уже есть
if (!$siteAccount) {
$email = null;
public function passwordEncrypt($password)
{
if ($this->config('password_type') == Ls::PASSWORD_TYPE_WHIRLPOOL) {
return base64_encode(hash('whirlpool', $password, true));
} else if ($this->config('password_type') == Ls::PASSWORD_TYPE_PBKDF2WITHHMACSHA1) {
$algorithm = "sha1";
$iterations = 1000;
$salt = random_bytes(24);
$hash = hash_pbkdf2($algorithm, $password, $salt, $iterations, 24, true);
return $algorithm . ":" . $iterations . ":" . base64_encode($salt) . ":" . base64_encode($hash);
}
return base64_encode(pack('H*', sha1(utf8_encode($password))));
}
public function checkHash($password, $hash_password)
{
if ($this->config('password_type') == Ls::PASSWORD_TYPE_WHIRLPOOL) {
$new_hash = base64_encode(hash('whirlpool', $password, true));
}
else if($this->config('password_type') == Ls::PASSWORD_TYPE_PBKDF2WITHHMACSHA1) {
$PBKDF2Hash = explode(':', $hash_password);
$algorithm = $PBKDF2Hash[0];
$iterations = intval($PBKDF2Hash[1]);
$salt = base64_decode($PBKDF2Hash[2]);
$serverPasswordHash = base64_decode($PBKDF2Hash[3]);
$currentPasswordHash = hash_pbkdf2($algorithm, $password, $salt, $iterations, 24, true);
return (strcmp($serverPasswordHash, $currentPasswordHash) === 0);
}
else {
$new_hash = base64_encode(pack('H*', sha1(utf8_encode($password))));
}
return $new_hash == $hash_password;
}
if ($account) {
if ($l2->checkHash($this->getPassword(), $account['password'])) {
// Аккаунта на сайте нет, создаю его так как на сервере он уже есть
if (!$siteAccount) {
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?