0
1
Fork 0

refs #5489 Account.sync(): bcryptPassword not used, removed

This commit is contained in:
Juan Ferrer 2023-06-15 13:14:01 +02:00
parent 74980fbdd7
commit 56395aa91b
1 changed files with 0 additions and 40 deletions

View File

@ -1,40 +0,0 @@
<?php
class Account {
static function trySync($db, $userName, $password = NULL) {
$sync = $db->getValue(
'SELECT COUNT(*) > 0 FROM account.userSync WHERE name = #',
[$userName]
);
if ($sync)
self::sync($db, $userName, $password);
}
static function sync($db, $userName, $password = NULL) {
$bcryptPassword = password_hash($password, PASSWORD_BCRYPT);
$userId = $db->getValue(
'SELECT id FROM account.user WHERE `name` = #',
[$userName]
);
$db->query(
'UPDATE account.user SET
bcryptPassword = #
WHERE id = #',
[$bcryptPassword, $userId]
);
$hasAccount = $db->getValue(
'SELECT COUNT(*) > 0
FROM account.user u
JOIN account.account a ON u.id = a.id
WHERE u.name = #',
[$userName]
);
if (!$hasAccount)
$db->query('DELETE FROM account.userSync WHERE name = #',
[$userName]
);
}
}