mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Define default user and password as constants
This commit is contained in:
parent
0ee637e56d
commit
7dccad35aa
@ -8,6 +8,11 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
namespace hyperion {
|
||||||
|
const char DEFAULT_USER[] = "Hyperion";
|
||||||
|
const char DEFAULT_PASSWORD[] = "hyperion";
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Authentication table interface
|
/// @brief Authentication table interface
|
||||||
///
|
///
|
||||||
@ -149,10 +154,10 @@ public:
|
|||||||
inline bool resetHyperionUser()
|
inline bool resetHyperionUser()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map["password"] = calcPasswordHashOfUser("Hyperion", "hyperion");
|
map["password"] = calcPasswordHashOfUser(hyperion::DEFAULT_USER, hyperion::DEFAULT_PASSWORD);
|
||||||
|
|
||||||
VectorPair cond;
|
VectorPair cond;
|
||||||
cond.append(CPair("user", "Hyperion"));
|
cond.append(CPair("user", hyperion::DEFAULT_USER));
|
||||||
return updateRecord(cond, map);
|
return updateRecord(cond, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <utils/Logger.h>
|
#include <utils/Logger.h>
|
||||||
#include <utils/settings.h>
|
#include <utils/settings.h>
|
||||||
|
|
||||||
|
#include <db/AuthTable.h>
|
||||||
|
|
||||||
//qt
|
//qt
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@ -172,7 +174,7 @@ public slots:
|
|||||||
/// @param usr the defined user
|
/// @param usr the defined user
|
||||||
/// @return The token
|
/// @return The token
|
||||||
///
|
///
|
||||||
QString getUserToken(const QString &usr = "Hyperion") const;
|
QString getUserToken(const QString &usr = hyperion::DEFAULT_USER) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Get all available token entries
|
/// @brief Get all available token entries
|
||||||
|
@ -417,7 +417,7 @@ bool API::updateHyperionPassword(const QString &password, const QString &newPass
|
|||||||
if (!_adminAuthorized)
|
if (!_adminAuthorized)
|
||||||
return false;
|
return false;
|
||||||
bool res;
|
bool res;
|
||||||
QMetaObject::invokeMethod(_authManager, "updateUserPassword", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, "Hyperion"), Q_ARG(QString, password), Q_ARG(QString, newPassword));
|
QMetaObject::invokeMethod(_authManager, "updateUserPassword", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, DEFAULT_USER), Q_ARG(QString, password), Q_ARG(QString, newPassword));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ bool API::getPendingTokenRequests(QVector<AuthManager::AuthDefinition> &map)
|
|||||||
bool API::isUserTokenAuthorized(const QString &userToken)
|
bool API::isUserTokenAuthorized(const QString &userToken)
|
||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
QMetaObject::invokeMethod(_authManager, "isUserTokenAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, "Hyperion"), Q_ARG(QString, userToken));
|
QMetaObject::invokeMethod(_authManager, "isUserTokenAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, DEFAULT_USER), Q_ARG(QString, userToken));
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
_authorized = true;
|
_authorized = true;
|
||||||
@ -521,7 +521,7 @@ bool API::isTokenAuthorized(const QString &token)
|
|||||||
bool API::isUserAuthorized(const QString &password)
|
bool API::isUserAuthorized(const QString &password)
|
||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
QMetaObject::invokeMethod(_authManager, "isUserAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, "Hyperion"), Q_ARG(QString, password));
|
QMetaObject::invokeMethod(_authManager, "isUserAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, DEFAULT_USER), Q_ARG(QString, password));
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
_authorized = true;
|
_authorized = true;
|
||||||
@ -535,7 +535,7 @@ bool API::isUserAuthorized(const QString &password)
|
|||||||
bool API::hasHyperionDefaultPw()
|
bool API::hasHyperionDefaultPw()
|
||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
QMetaObject::invokeMethod(_authManager, "isUserAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, "Hyperion"), Q_ARG(QString, "hyperion"));
|
QMetaObject::invokeMethod(_authManager, "isUserAuthorized", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, res), Q_ARG(QString, DEFAULT_USER), Q_ARG(QString, DEFAULT_PASSWORD));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ AuthManager::AuthManager(QObject *parent, bool readonlyMode)
|
|||||||
connect(_authBlockTimer, &QTimer::timeout, this, &AuthManager::checkAuthBlockTimeout);
|
connect(_authBlockTimer, &QTimer::timeout, this, &AuthManager::checkAuthBlockTimeout);
|
||||||
|
|
||||||
// init with default user and password
|
// init with default user and password
|
||||||
if (!_authTable->userExist("Hyperion"))
|
if (!_authTable->userExist(hyperion::DEFAULT_USER))
|
||||||
{
|
{
|
||||||
_authTable->createUser("Hyperion", "hyperion");
|
_authTable->createUser(hyperion::DEFAULT_USER, hyperion::DEFAULT_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update Hyperion user token on startup
|
// update Hyperion user token on startup
|
||||||
_authTable->setUserToken("Hyperion");
|
_authTable->setUserToken(hyperion::DEFAULT_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthManager::AuthDefinition AuthManager::createToken(const QString &comment)
|
AuthManager::AuthDefinition AuthManager::createToken(const QString &comment)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user