mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-30 18:27:49 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -37,15 +37,12 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
while (Running_) {
|
while (Running_) {
|
||||||
Poco::Thread::trySleep(2000);
|
Poco::Thread::trySleep(2000);
|
||||||
DBGLINE
|
|
||||||
if (!Running_)
|
if (!Running_)
|
||||||
break;
|
break;
|
||||||
std::vector<SecurityObjects::ActionLink> Links;
|
std::vector<SecurityObjects::ActionLink> Links;
|
||||||
{
|
{
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(Mutex_);
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().GetActions(Links);
|
StorageService()->ActionLinksDB().GetActions(Links);
|
||||||
DBGLINE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Links.empty())
|
if (Links.empty())
|
||||||
@@ -56,120 +53,88 @@ namespace OpenWifi {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
SecurityObjects::UserInfo UInfo;
|
SecurityObjects::UserInfo UInfo;
|
||||||
DBGLINE
|
|
||||||
if ((i.action == OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD ||
|
if ((i.action == OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD ||
|
||||||
i.action == OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL) &&
|
i.action == OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL) &&
|
||||||
!StorageService()->UserDB().GetUserById(i.userId, UInfo)) {
|
!StorageService()->UserDB().GetUserById(i.userId, UInfo)) {
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().CancelAction(i.id);
|
StorageService()->ActionLinksDB().CancelAction(i.id);
|
||||||
DBGLINE
|
|
||||||
continue;
|
continue;
|
||||||
} else if ((i.action ==
|
} else if ((i.action ==
|
||||||
OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD ||
|
OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD ||
|
||||||
i.action == OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL ||
|
i.action == OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL ||
|
||||||
i.action == OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP) &&
|
i.action == OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP) &&
|
||||||
!StorageService()->SubDB().GetUserById(i.userId, UInfo)) {
|
!StorageService()->SubDB().GetUserById(i.userId, UInfo)) {
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().CancelAction(i.id);
|
StorageService()->ActionLinksDB().CancelAction(i.id);
|
||||||
DBGLINE
|
|
||||||
continue;
|
continue;
|
||||||
} else if ((i.action == OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION) &&
|
} else if ((i.action == OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION) &&
|
||||||
(OpenWifi::Now() - i.created) > (24 * 60 * 60)) {
|
(OpenWifi::Now() - i.created) > (24 * 60 * 60)) {
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().CancelAction(i.id);
|
StorageService()->ActionLinksDB().CancelAction(i.id);
|
||||||
DBGLINE
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBGLINE
|
|
||||||
switch (i.action) {
|
switch (i.action) {
|
||||||
case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: {
|
case OpenWifi::SecurityObjects::LinkActions::FORGOT_PASSWORD: {
|
||||||
DBGLINE
|
|
||||||
if (AuthService()->SendEmailToUser(i.id, UInfo.email,
|
if (AuthService()->SendEmailToUser(i.id, UInfo.email,
|
||||||
MessagingTemplates::FORGOT_PASSWORD)) {
|
MessagingTemplates::FORGOT_PASSWORD)) {
|
||||||
poco_information(
|
poco_information(
|
||||||
Logger(), fmt::format("Send password reset link to {}", UInfo.email));
|
Logger(), fmt::format("Send password reset link to {}", UInfo.email));
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: {
|
case OpenWifi::SecurityObjects::LinkActions::VERIFY_EMAIL: {
|
||||||
DBGLINE
|
|
||||||
if (AuthService()->SendEmailToUser(i.id, UInfo.email,
|
if (AuthService()->SendEmailToUser(i.id, UInfo.email,
|
||||||
MessagingTemplates::EMAIL_VERIFICATION)) {
|
MessagingTemplates::EMAIL_VERIFICATION)) {
|
||||||
DBGLINE
|
|
||||||
poco_information(Logger(), fmt::format("Send email verification link to {}",
|
poco_information(Logger(), fmt::format("Send email verification link to {}",
|
||||||
UInfo.email));
|
UInfo.email));
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION: {
|
case OpenWifi::SecurityObjects::LinkActions::EMAIL_INVITATION: {
|
||||||
DBGLINE
|
|
||||||
if (AuthService()->SendEmailToUser(i.id, UInfo.email,
|
if (AuthService()->SendEmailToUser(i.id, UInfo.email,
|
||||||
MessagingTemplates::EMAIL_INVITATION)) {
|
MessagingTemplates::EMAIL_INVITATION)) {
|
||||||
DBGLINE
|
|
||||||
poco_information(
|
poco_information(
|
||||||
Logger(), fmt::format("Send new subscriber email invitation link to {}",
|
Logger(), fmt::format("Send new subscriber email invitation link to {}",
|
||||||
UInfo.email));
|
UInfo.email));
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: {
|
case OpenWifi::SecurityObjects::LinkActions::SUB_FORGOT_PASSWORD: {
|
||||||
if (AuthService()->SendEmailToSubUser(i.id, UInfo.email,
|
if (AuthService()->SendEmailToSubUser(i.id, UInfo.email,
|
||||||
MessagingTemplates::SUB_FORGOT_PASSWORD,"")) {
|
MessagingTemplates::SUB_FORGOT_PASSWORD,"")) {
|
||||||
DBGLINE
|
|
||||||
poco_information(
|
poco_information(
|
||||||
Logger(),
|
Logger(),
|
||||||
fmt::format("Send subscriber password reset link to {}", UInfo.email));
|
fmt::format("Send subscriber password reset link to {}", UInfo.email));
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: {
|
case OpenWifi::SecurityObjects::LinkActions::SUB_VERIFY_EMAIL: {
|
||||||
if (AuthService()->SendEmailToSubUser(
|
if (AuthService()->SendEmailToSubUser(
|
||||||
i.id, UInfo.email, MessagingTemplates::SUB_EMAIL_VERIFICATION,"")) {
|
i.id, UInfo.email, MessagingTemplates::SUB_EMAIL_VERIFICATION,"")) {
|
||||||
DBGLINE
|
|
||||||
poco_information(
|
poco_information(
|
||||||
Logger(), fmt::format("Send subscriber email verification link to {}",
|
Logger(), fmt::format("Send subscriber email verification link to {}",
|
||||||
UInfo.email));
|
UInfo.email));
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: {
|
case OpenWifi::SecurityObjects::LinkActions::SUB_SIGNUP: {
|
||||||
DBGLINE
|
|
||||||
auto Signup = Poco::StringTokenizer(UInfo.signingUp, ":");
|
auto Signup = Poco::StringTokenizer(UInfo.signingUp, ":");
|
||||||
DBGLINE
|
|
||||||
if (AuthService()->SendEmailToSubUser(
|
if (AuthService()->SendEmailToSubUser(
|
||||||
i.id, UInfo.email, MessagingTemplates::SUB_SIGNUP_VERIFICATION,
|
i.id, UInfo.email, MessagingTemplates::SUB_SIGNUP_VERIFICATION,
|
||||||
Signup.count() == 1 ? "" : Signup[0])) {
|
Signup.count() == 1 ? "" : Signup[0])) {
|
||||||
DBGLINE
|
|
||||||
poco_information(
|
poco_information(
|
||||||
Logger(),
|
Logger(),
|
||||||
fmt::format("Send new subscriber email verification link to {}",
|
fmt::format("Send new subscriber email verification link to {}",
|
||||||
UInfo.email));
|
UInfo.email));
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
DBGLINE
|
|
||||||
StorageService()->ActionLinksDB().SentAction(i.id);
|
StorageService()->ActionLinksDB().SentAction(i.id);
|
||||||
DBGLINE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -798,12 +798,9 @@ namespace OpenWifi {
|
|||||||
const std::string &OperatorName) {
|
const std::string &OperatorName) {
|
||||||
SecurityObjects::UserInfo UInfo;
|
SecurityObjects::UserInfo UInfo;
|
||||||
|
|
||||||
DBGLINE
|
|
||||||
if (StorageService()->SubDB().GetUserByEmail(Email, UInfo)) {
|
if (StorageService()->SubDB().GetUserByEmail(Email, UInfo)) {
|
||||||
switch (Reason) {
|
switch (Reason) {
|
||||||
DBGLINE
|
|
||||||
case MessagingTemplates::SUB_FORGOT_PASSWORD: {
|
case MessagingTemplates::SUB_FORGOT_PASSWORD: {
|
||||||
DBGLINE
|
|
||||||
MessageAttributes Attrs;
|
MessageAttributes Attrs;
|
||||||
Attrs[RECIPIENT_EMAIL] = UInfo.email;
|
Attrs[RECIPIENT_EMAIL] = UInfo.email;
|
||||||
Attrs[LOGO] = GetSubLogoAssetURI();
|
Attrs[LOGO] = GetSubLogoAssetURI();
|
||||||
@@ -812,19 +809,15 @@ DBGLINE
|
|||||||
"/actionLink?action=sub_password_reset&id=" + LinkId;
|
"/actionLink?action=sub_password_reset&id=" + LinkId;
|
||||||
Attrs[ACTION_LINK_HTML] =
|
Attrs[ACTION_LINK_HTML] =
|
||||||
"/api/v1/actionLink?action=sub_password_reset&id=" + LinkId;
|
"/api/v1/actionLink?action=sub_password_reset&id=" + LinkId;
|
||||||
DBGLINE
|
|
||||||
SMTPMailerService()->AddSubVars(Attrs);
|
SMTPMailerService()->AddSubVars(Attrs);
|
||||||
DBGLINE
|
|
||||||
SMTPMailerService()->SendMessage(
|
SMTPMailerService()->SendMessage(
|
||||||
UInfo.email,
|
UInfo.email,
|
||||||
MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD,
|
MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD,
|
||||||
OperatorName),
|
OperatorName),
|
||||||
Attrs, true);
|
Attrs, true);
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MessagingTemplates::SUB_EMAIL_VERIFICATION: {
|
case MessagingTemplates::SUB_EMAIL_VERIFICATION: {
|
||||||
DBGLINE
|
|
||||||
MessageAttributes Attrs;
|
MessageAttributes Attrs;
|
||||||
Attrs[RECIPIENT_EMAIL] = UInfo.email;
|
Attrs[RECIPIENT_EMAIL] = UInfo.email;
|
||||||
Attrs[LOGO] = GetSubLogoAssetURI();
|
Attrs[LOGO] = GetSubLogoAssetURI();
|
||||||
@@ -833,20 +826,16 @@ DBGLINE
|
|||||||
"/actionLink?action=sub_email_verification&id=" + LinkId;
|
"/actionLink?action=sub_email_verification&id=" + LinkId;
|
||||||
Attrs[ACTION_LINK_HTML] =
|
Attrs[ACTION_LINK_HTML] =
|
||||||
"/api/v1/actionLink?action=sub_email_verification&id=" + LinkId;
|
"/api/v1/actionLink?action=sub_email_verification&id=" + LinkId;
|
||||||
DBGLINE
|
|
||||||
SMTPMailerService()->AddSubVars(Attrs);
|
SMTPMailerService()->AddSubVars(Attrs);
|
||||||
DBGLINE
|
|
||||||
SMTPMailerService()->SendMessage(
|
SMTPMailerService()->SendMessage(
|
||||||
UInfo.email,
|
UInfo.email,
|
||||||
MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION,
|
MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION,
|
||||||
OperatorName),
|
OperatorName),
|
||||||
Attrs, true);
|
Attrs, true);
|
||||||
UInfo.waitingForEmailCheck = true;
|
UInfo.waitingForEmailCheck = true;
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MessagingTemplates::SUB_SIGNUP_VERIFICATION: {
|
case MessagingTemplates::SUB_SIGNUP_VERIFICATION: {
|
||||||
DBGLINE
|
|
||||||
MessageAttributes Attrs;
|
MessageAttributes Attrs;
|
||||||
Attrs[RECIPIENT_EMAIL] = UInfo.email;
|
Attrs[RECIPIENT_EMAIL] = UInfo.email;
|
||||||
Attrs[LOGO] = GetSubLogoAssetURI();
|
Attrs[LOGO] = GetSubLogoAssetURI();
|
||||||
@@ -855,25 +844,20 @@ DBGLINE
|
|||||||
"/actionLink?action=signup_verification&id=" + LinkId;
|
"/actionLink?action=signup_verification&id=" + LinkId;
|
||||||
Attrs[ACTION_LINK_HTML] =
|
Attrs[ACTION_LINK_HTML] =
|
||||||
"/api/v1/actionLink?action=signup_verification&id=" + LinkId;
|
"/api/v1/actionLink?action=signup_verification&id=" + LinkId;
|
||||||
DBGLINE
|
|
||||||
SMTPMailerService()->AddSubVars(Attrs);
|
SMTPMailerService()->AddSubVars(Attrs);
|
||||||
DBGLINE
|
|
||||||
SMTPMailerService()->SendMessage(
|
SMTPMailerService()->SendMessage(
|
||||||
UInfo.email,
|
UInfo.email,
|
||||||
MessagingTemplates::TemplateName(MessagingTemplates::SUB_SIGNUP_VERIFICATION,
|
MessagingTemplates::TemplateName(MessagingTemplates::SUB_SIGNUP_VERIFICATION,
|
||||||
OperatorName),
|
OperatorName),
|
||||||
Attrs, true);
|
Attrs, true);
|
||||||
UInfo.waitingForEmailCheck = true;
|
UInfo.waitingForEmailCheck = true;
|
||||||
DBGLINE
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DBGLINE
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DBGLINE
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user