mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-29 17:28:41 -04:00
added passwd request for webUI at start of rs-service. All this should be later handled using commandline options
This commit is contained in:
parent
90d0686e88
commit
158da65fc4
1 changed files with 33 additions and 4 deletions
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "util/stacktrace.h"
|
#include "util/stacktrace.h"
|
||||||
|
#include "jsonapi/jsonapi.h"
|
||||||
|
|
||||||
CrashStackTrace gCrashStackTrace;
|
CrashStackTrace gCrashStackTrace;
|
||||||
|
|
||||||
|
@ -91,11 +92,11 @@ std::string readStringFromKeyboard(const char *prompt, bool show_asterisk=true)
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
class NotifyTxt: public NotifyClient
|
class RsServiceNotify: public NotifyClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NotifyTxt(){}
|
RsServiceNotify(){}
|
||||||
virtual ~NotifyTxt() {}
|
virtual ~RsServiceNotify() {}
|
||||||
|
|
||||||
virtual bool askForPassword(const std::string& title, const std::string& question, bool prev_is_bad, std::string& password,bool& cancel)
|
virtual bool askForPassword(const std::string& title, const std::string& question, bool prev_is_bad, std::string& password,bool& cancel)
|
||||||
{
|
{
|
||||||
|
@ -126,15 +127,40 @@ int main(int argc, char* argv[])
|
||||||
RsControl::earlyInitNotificationSystem();
|
RsControl::earlyInitNotificationSystem();
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
NotifyTxt *notify = new NotifyTxt();
|
RsServiceNotify *notify = new RsServiceNotify();
|
||||||
rsNotify->registerNotifyClient(notify);
|
rsNotify->registerNotifyClient(notify);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
std::string webui_pass1 = "Y";
|
||||||
|
std::string webui_pass2 = "N";
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
webui_pass1 = readStringFromKeyboard("Please register a password for the web interface: ");
|
||||||
|
webui_pass2 = readStringFromKeyboard("Please enter the same password again : ");
|
||||||
|
|
||||||
|
if(webui_pass1 != webui_pass2)
|
||||||
|
{
|
||||||
|
std::cerr << "Passwords do not match!" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(webui_pass1.empty())
|
||||||
|
{
|
||||||
|
std::cerr << "Password cannot be empty!" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(RsInit::InitRetroShare(argc, argv, true))
|
if(RsInit::InitRetroShare(argc, argv, true))
|
||||||
{
|
{
|
||||||
std::cerr << "Could not properly init Retroshare core." << std::endl;
|
std::cerr << "Could not properly init Retroshare core." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
rsControl->setShutdownCallback(QCoreApplication::exit);
|
rsControl->setShutdownCallback(QCoreApplication::exit);
|
||||||
|
|
||||||
|
@ -146,6 +172,9 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
#else
|
#else
|
||||||
|
if(jsonApiServer)
|
||||||
|
jsonApiServer->authorizeToken("webui:"+webui_pass1);
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue