mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
resetPassword rework
This commit is contained in:
parent
5f48a007be
commit
227f60496d
@ -16,9 +16,14 @@ class AuthTable : public DBManager
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// construct wrapper with auth table
|
/// construct wrapper with auth table
|
||||||
AuthTable(QObject* parent = nullptr)
|
AuthTable(const QString& rootPath = "", QObject* parent = nullptr)
|
||||||
: DBManager(parent)
|
: DBManager(parent)
|
||||||
{
|
{
|
||||||
|
if(!rootPath.isEmpty()){
|
||||||
|
// Init Hyperion database usage
|
||||||
|
setRootPath(rootPath);
|
||||||
|
setDatabaseName("hyperion");
|
||||||
|
}
|
||||||
// init Auth table
|
// init Auth table
|
||||||
setTable("auth");
|
setTable("auth");
|
||||||
// create table columns
|
// create table columns
|
||||||
|
@ -12,7 +12,7 @@ AuthManager* AuthManager::manager = nullptr;
|
|||||||
|
|
||||||
AuthManager::AuthManager(QObject* parent)
|
AuthManager::AuthManager(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, _authTable(new AuthTable(this))
|
, _authTable(new AuthTable("",this))
|
||||||
, _metaTable(new MetaTable(this))
|
, _metaTable(new MetaTable(this))
|
||||||
, _pendingRequests()
|
, _pendingRequests()
|
||||||
, _authRequired(true)
|
, _authRequired(true)
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
HyperionDaemon* HyperionDaemon::daemon = nullptr;
|
HyperionDaemon* HyperionDaemon::daemon = nullptr;
|
||||||
|
|
||||||
HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bool& logLvlOverwrite, const bool& resetPassword)
|
HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bool& logLvlOverwrite)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, _log(Logger::getInstance("DAEMON"))
|
, _log(Logger::getInstance("DAEMON"))
|
||||||
, _instanceManager(new HyperionIManager(rootPath, this))
|
, _instanceManager(new HyperionIManager(rootPath, this))
|
||||||
@ -93,15 +93,6 @@ HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bo
|
|||||||
if(!logLvlOverwrite)
|
if(!logLvlOverwrite)
|
||||||
handleSettingsUpdate(settings::LOGGER, getSetting(settings::LOGGER));
|
handleSettingsUpdate(settings::LOGGER, getSetting(settings::LOGGER));
|
||||||
|
|
||||||
// reset password if requested from cmd
|
|
||||||
if(resetPassword){
|
|
||||||
if(_authManager->resetHyperionUser()){
|
|
||||||
Info(_log, "Password successfully resetted")
|
|
||||||
} else {
|
|
||||||
Error(_log, "Failed to reset password")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// init EffectFileHandler
|
// init EffectFileHandler
|
||||||
EffectFileHandler* efh = new EffectFileHandler(rootPath, getSetting(settings::EFFECTS), this);
|
EffectFileHandler* efh = new EffectFileHandler(rootPath, getSetting(settings::EFFECTS), this);
|
||||||
connect(this, &HyperionDaemon::settingsChanged, efh, &EffectFileHandler::handleSettingsUpdate);
|
connect(this, &HyperionDaemon::settingsChanged, efh, &EffectFileHandler::handleSettingsUpdate);
|
||||||
|
@ -72,7 +72,7 @@ class HyperionDaemon : public QObject
|
|||||||
friend SysTray;
|
friend SysTray;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HyperionDaemon(QString rootPath, QObject *parent, const bool& logLvlOverwrite, const bool& resetPassword);
|
HyperionDaemon(QString rootPath, QObject *parent, const bool& logLvlOverwrite);
|
||||||
~HyperionDaemon();
|
~HyperionDaemon();
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <utils/FileUtils.h>
|
#include <utils/FileUtils.h>
|
||||||
#include <commandline/Parser.h>
|
#include <commandline/Parser.h>
|
||||||
#include <commandline/IntOption.h>
|
#include <commandline/IntOption.h>
|
||||||
|
#include <../../include/db/AuthTable.h>
|
||||||
|
|
||||||
#ifdef ENABLE_X11
|
#ifdef ENABLE_X11
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
@ -335,10 +336,25 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
Info(log, "Set user data path to '%s'", QSTRING_CSTR(mDir.absolutePath()));
|
Info(log, "Set user data path to '%s'", QSTRING_CSTR(mDir.absolutePath()));
|
||||||
|
|
||||||
|
// reset Password without spawning daemon
|
||||||
|
if(parser.isSet(resetPassword))
|
||||||
|
{
|
||||||
|
AuthTable* table = new AuthTable(userDataPath);
|
||||||
|
if(table->resetHyperionUser()){
|
||||||
|
Info(log,"Password reset successfull");
|
||||||
|
delete table;
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
Error(log,"Failed to reset password!");
|
||||||
|
delete table;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HyperionDaemon* hyperiond = nullptr;
|
HyperionDaemon* hyperiond = nullptr;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
hyperiond = new HyperionDaemon(userDataPath, qApp, bool(logLevelCheck), parser.isSet(resetPassword));
|
hyperiond = new HyperionDaemon(userDataPath, qApp, bool(logLevelCheck));
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user