mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2026-01-27 10:23:15 +00:00
Implementing several adjustments for security reasons.
This commit is contained in:
64
src/ActionLinkManager.cpp
Normal file
64
src/ActionLinkManager.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user