work with old qt

This commit is contained in:
scatterflower 2020-10-06 14:05:45 -05:00
parent d76301cfcd
commit 5dd834c3af
3 changed files with 18 additions and 1 deletions

View File

@ -10,7 +10,7 @@ on: [push, pull_request]
jobs:
build-linux:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:

View File

@ -28,7 +28,10 @@
#include <QHostAddress>
#include <QTcpSocket>
#include <QDateTime>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
class Server;

View File

@ -164,7 +164,14 @@ void AOClient::cmdSetRootPass(int argc, QStringList argv)
settings.beginGroup("Options");
settings.setValue("auth", "advanced");
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand(QDateTime::currentMSecsSinceEpoch());
quint32 upper_salt = qrand();
quint32 lower_salt = qrand();
quint64 salt_number = (upper_salt << 32) | lower_salt;
#else
quint64 salt_number = QRandomGenerator::system()->generate64();
#endif
QString salt = QStringLiteral("%1").arg(salt_number, 16, 16, QLatin1Char('0'));
server->db_manager->createUser("root", salt, argv[0], ACLFlags.value("SUPER"));
@ -206,7 +213,14 @@ void AOClient::cmdBgUnlock(int argc, QStringList argv)
void AOClient::cmdAddUser(int argc, QStringList argv)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand(QDateTime::currentMSecsSinceEpoch());
quint32 upper_salt = qrand();
quint32 lower_salt = qrand();
quint64 salt_number = (upper_salt << 32) | lower_salt;
#else
quint64 salt_number = QRandomGenerator::system()->generate64();
#endif
QString salt = QStringLiteral("%1").arg(salt_number, 16, 16, QLatin1Char('0'));
if (server->db_manager->createUser(argv[0], salt, argv[1], ACLFlags.value("NONE")))