Implementing several adjustments for security reasons.

This commit is contained in:
stephb9959
2021-11-09 11:33:20 -08:00
parent 7b19143d6f
commit 45a50483be
34 changed files with 862 additions and 272 deletions

64
src/ActionLinkManager.cpp Normal file
View File

@@ -0,0 +1,64 @@
//
// Created by stephane bourque on 2021-11-08.
//
#include "ActionLinkManager.h"
#include "StorageService.h"
namespace OpenWifi {
int ActionLinkManager::Start() {
if(!Running_)
Thr_.start(*this);
return 0;
}
void ActionLinkManager::Stop() {
if(Running_) {
Running_ = false;
Thr_.wakeUp();
Thr_.join();
}
}
void ActionLinkManager::run() {
Running_ = true ;
while(Running_) {
Poco::Thread::trySleep(2000);
if(!Running_)
break;
std::vector<SecurityObjects::ActionLink> Links;
{
std::lock_guard G(Mutex_);
Storage().GetActions(Links);
}
if(Links.empty())
continue;
for(auto &i:Links) {
if(!Running_)
break;
if(i.action=="forgot_password") {
if(AuthService::SendEmailToUser(i.id, i.userId, AuthService::FORGOT_PASSWORD)) {
Logger_.information(Poco::format("Send password reset link to %s",i.userId));
}
Storage().SentAction(i.id);
} else if (i.action=="email_verification") {
if(AuthService::SendEmailToUser(i.id, i.userId, AuthService::EMAIL_VERIFICATION)) {
Logger_.information(Poco::format("Send password reset link to %s",i.userId));
}
Storage().SentAction(i.id);
} else {
Storage().SentAction(i.id);
}
}
}
}
}