diff --git a/build b/build index cabf43b..410b14d 100644 --- a/build +++ b/build @@ -1 +1 @@ -24 \ No newline at end of file +25 \ No newline at end of file diff --git a/src/AuthService.cpp b/src/AuthService.cpp index b9df0dc..8aa20cd 100644 --- a/src/AuthService.cpp +++ b/src/AuthService.cpp @@ -596,14 +596,14 @@ namespace OpenWifi { Attrs[LOGO] = AuthService::GetLogoAssetURI(); Attrs[SUBJECT] = "Login validation code"; Attrs[CHALLENGE_CODE] = Challenge; - return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::VERIFICATION_CODE), Attrs); + return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::VERIFICATION_CODE), Attrs, false); } else { MessageAttributes Attrs; Attrs[RECIPIENT_EMAIL] = UInfo.userinfo.email; Attrs[LOGO] = AuthService::GetSubLogoAssetURI(); Attrs[SUBJECT] = "Login validation code"; Attrs[CHALLENGE_CODE] = Challenge; - return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_VERIFICATION_CODE,OperatorParts[0]), Attrs); + return SMTPMailerService()->SendMessage(UInfo.userinfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_VERIFICATION_CODE,OperatorParts[0]), Attrs, true ); } } @@ -620,7 +620,7 @@ namespace OpenWifi { Attrs[SUBJECT] = "Password reset link"; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=password_reset&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=password_reset&id=" + LinkId ; - SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::FORGOT_PASSWORD), Attrs); + SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::FORGOT_PASSWORD), Attrs, false); } break; @@ -631,7 +631,7 @@ namespace OpenWifi { Attrs[SUBJECT] = "e-mail Address Verification"; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=email_verification&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=email_verification&id=" + LinkId ; - SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_VERIFICATION), Attrs); + SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_VERIFICATION), Attrs, false); UInfo.waitingForEmailCheck = true; } break; @@ -643,7 +643,7 @@ namespace OpenWifi { Attrs[SUBJECT] = "e-mail Invitation"; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=email_invitation&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=email_invitation&id=" + LinkId ; - SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_INVITATION), Attrs); + SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::EMAIL_INVITATION), Attrs, false); UInfo.waitingForEmailCheck = true; } break; @@ -669,7 +669,7 @@ namespace OpenWifi { Attrs[SUBJECT] = "Password reset link"; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=sub_password_reset&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=sub_password_reset&id=" + LinkId ; - SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD, OperatorName), Attrs); + SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_FORGOT_PASSWORD, OperatorName), Attrs, true); } break; @@ -680,7 +680,7 @@ namespace OpenWifi { Attrs[SUBJECT] = "e-mail Address Verification"; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=sub_email_verification&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=sub_email_verification&id=" + LinkId ; - SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION, OperatorName), Attrs); + SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SUB_EMAIL_VERIFICATION, OperatorName), Attrs, true); UInfo.waitingForEmailCheck = true; } break; @@ -692,7 +692,7 @@ namespace OpenWifi { Attrs[SUBJECT] = "Signup e-mail Address Verification"; Attrs[ACTION_LINK] = MicroServiceGetPublicAPIEndPoint() + "/actionLink?action=signup_verification&id=" + LinkId ; Attrs[ACTION_LINK_HTML] = "/api/v1/actionLink?action=signup_verification&id=" + LinkId ; - SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SIGNUP_VERIFICATION, OperatorName), Attrs); + SMTPMailerService()->SendMessage(UInfo.email, MessagingTemplates::TemplateName(MessagingTemplates::SIGNUP_VERIFICATION, OperatorName), Attrs, true); UInfo.waitingForEmailCheck = true; } break; diff --git a/src/MessagingTemplates.h b/src/MessagingTemplates.h index 7289a1d..df0a892 100644 --- a/src/MessagingTemplates.h +++ b/src/MessagingTemplates.h @@ -49,11 +49,11 @@ namespace OpenWifi { } static std::string Logo(const std::string &OperatorName = "" ) { - return AddOperator("logo.jpg", OperatorName); + return AddOperator("logo.png", OperatorName); } static std::string SubLogo(const std::string &OperatorName = "" ) { - return AddOperator("sub_logo.jpg", OperatorName); + return AddOperator("sub_logo.png", OperatorName); } private: diff --git a/src/RESTAPI/RESTAPI_email_handler.cpp b/src/RESTAPI/RESTAPI_email_handler.cpp index 48c02e3..d9ccb74 100644 --- a/src/RESTAPI/RESTAPI_email_handler.cpp +++ b/src/RESTAPI/RESTAPI_email_handler.cpp @@ -24,7 +24,7 @@ namespace OpenWifi { Attrs[SUBJECT] = Obj->get("subject").toString(); Attrs[TEXT] = Obj->get("text").toString(); Attrs[SENDER] = Obj->get("from").toString(); - if(SMTPMailerService()->SendMessage(Recipient, "password_reset.txt", Attrs)) { + if(SMTPMailerService()->SendMessage(Recipient, "password_reset.txt", Attrs, false)) { return OK(); } return ReturnStatus(Poco::Net::HTTPResponse::HTTP_SERVICE_UNAVAILABLE); diff --git a/src/SMTPMailerService.cpp b/src/SMTPMailerService.cpp index 70df0ad..9572305 100644 --- a/src/SMTPMailerService.cpp +++ b/src/SMTPMailerService.cpp @@ -57,13 +57,14 @@ namespace OpenWifi { LoadMyConfig(); } - bool SMTPMailerService::SendMessage([[maybe_unused]] const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs) { + bool SMTPMailerService::SendMessage([[maybe_unused]] const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs, bool Subscriber) { std::lock_guard G(Mutex_); PendingMessages_.push_back(MessageEvent{.Posted= OpenWifi::Now(), .LastTry=0, .Sent=0, .TemplateName=Name, - .Attrs=Attrs}); + .Attrs=Attrs, + .Subscriber=Subscriber}); return true; } @@ -158,7 +159,7 @@ namespace OpenWifi { auto Logo = Msg.Attrs.find(LOGO); if(Logo!=Msg.Attrs.end()) { try { - Poco::File LogoFile(EmailLogo_); + Poco::File LogoFile( Msg.Subscriber ? AuthService::GetSubLogoAssetFileName() : AuthService::GetLogoAssetFileName ()); std::ifstream IF(LogoFile.path()); std::ostringstream OS; Poco::StreamCopier::copyStream(IF, OS); diff --git a/src/SMTPMailerService.h b/src/SMTPMailerService.h index a048e8f..d82906f 100644 --- a/src/SMTPMailerService.h +++ b/src/SMTPMailerService.h @@ -76,13 +76,14 @@ namespace OpenWifi { uint64_t Sent=0; std::string TemplateName; MessageAttributes Attrs; + bool Subscriber=false; }; void run() override; int Start() override; void Stop() override; - bool SendMessage(const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs); + bool SendMessage(const std::string &Recipient, const std::string &Name, const MessageAttributes &Attrs, bool Subscriber); MessageSendStatus SendIt(const MessageEvent &Msg); void LoadMyConfig(); void reinitialize(Poco::Util::Application &self) override; @@ -104,7 +105,7 @@ namespace OpenWifi { std::atomic_bool Running_=false; bool Enabled_=false; bool UseHTML_=false; - std::string EmailLogo_{"logo.jpg"}; + std::string EmailLogo_{"logo.png"}; SMTPMailerService() noexcept: SubSystemServer("SMTPMailer", "MAILER-SVR", "smtpmailer") diff --git a/templates/email_invitation.html b/templates/email_invitation.html index 65e6d90..330b661 100644 --- a/templates/email_invitation.html +++ b/templates/email_invitation.html @@ -1,14 +1,526 @@ - - - - - eMail Invitation + + + Your Invitation To The OpenWifi System + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/email_verification.html b/templates/email_verification.html index 0987dd3..b3a025b 100644 --- a/templates/email_verification.html +++ b/templates/email_verification.html @@ -1,13 +1,527 @@ - - - - - eMail Verification + + + Email Confirmation + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/email_verification.txt b/templates/email_verification.txt index 5b1a4bf..f251762 100644 --- a/templates/email_verification.txt +++ b/templates/email_verification.txt @@ -1,7 +1,6 @@ Dear ${RECIPIENT_EMAIL}, - Before you can access the system, you must validate your e-mail address. Please click on the link below - to complete this task. + Before you can access the system, you must validate your e-mail address. Please click on the link below to complete this task. ${ACTION_LINK} diff --git a/templates/logo.jpg b/templates/logo.jpg deleted file mode 100644 index 6bce07d..0000000 Binary files a/templates/logo.jpg and /dev/null differ diff --git a/wwwassets/the_logo.png b/templates/logo.png similarity index 100% rename from wwwassets/the_logo.png rename to templates/logo.png diff --git a/templates/password_reset.html b/templates/password_reset.html index 5a3ee06..1377671 100644 --- a/templates/password_reset.html +++ b/templates/password_reset.html @@ -1,19 +1,523 @@ - - - - - Password Reset + + + Password Reset + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/signup_verification.html b/templates/signup_verification.html index 566549b..f501ce1 100644 --- a/templates/signup_verification.html +++ b/templates/signup_verification.html @@ -1,10 +1,527 @@ - - - - - Title - - + + + Sign Up Verification + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/signup_verification.txt b/templates/signup_verification.txt index 5b1a4bf..cc9c42c 100644 --- a/templates/signup_verification.txt +++ b/templates/signup_verification.txt @@ -1,10 +1,8 @@ Dear ${RECIPIENT_EMAIL}, - Before you can access the system, you must validate your e-mail address. Please click on the link below - to complete this task. + Before you can access the system, you must validate your e-mail address. Please click on the button below and follow the instructions. ${ACTION_LINK} - And follow the instructions. Thank you! \ No newline at end of file diff --git a/templates/sub_email_verification.html b/templates/sub_email_verification.html index e69de29..85864a7 100644 --- a/templates/sub_email_verification.html +++ b/templates/sub_email_verification.html @@ -0,0 +1,527 @@ + + + Email Confirmation + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/sub_email_verification.txt b/templates/sub_email_verification.txt index e69de29..f251762 100644 --- a/templates/sub_email_verification.txt +++ b/templates/sub_email_verification.txt @@ -0,0 +1,9 @@ +Dear ${RECIPIENT_EMAIL}, + + Before you can access the system, you must validate your e-mail address. Please click on the link below to complete this task. + + ${ACTION_LINK} + + And follow the instructions. + +Thank you! \ No newline at end of file diff --git a/templates/sub_password_reset.html b/templates/sub_password_reset.html index e69de29..27afa52 100644 --- a/templates/sub_password_reset.html +++ b/templates/sub_password_reset.html @@ -0,0 +1,523 @@ + + + Password Reset + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/sub_password_reset.txt b/templates/sub_password_reset.txt index e69de29..7b3f964 100644 --- a/templates/sub_password_reset.txt +++ b/templates/sub_password_reset.txt @@ -0,0 +1,9 @@ +Dear ${RECIPIENT_EMAIL}, + + You have requested us to reset your password. Please click on the link below + + ${ACTION_LINK} + + And follow the instructions. + +Thank you! \ No newline at end of file diff --git a/templates/sub_verification_code.html b/templates/sub_verification_code.html index e69de29..3cefde8 100644 --- a/templates/sub_verification_code.html +++ b/templates/sub_verification_code.html @@ -0,0 +1,515 @@ + + + Verification Code + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/sub_verification_code.txt b/templates/sub_verification_code.txt index e69de29..51551eb 100644 --- a/templates/sub_verification_code.txt +++ b/templates/sub_verification_code.txt @@ -0,0 +1,10 @@ +Dear ${RECIPIENT_EMAIL}, + + You have requested your login validation. Please enter the following code on the login screen: + + ${CHALLENGE_CODE} + + If you are not trying to login, please login and change your password. Someone may be trying to + access your account illegally. + +Thank you! \ No newline at end of file diff --git a/templates/verification_code.html b/templates/verification_code.html index e69de29..97aa829 100644 --- a/templates/verification_code.html +++ b/templates/verification_code.html @@ -0,0 +1,515 @@ + + + Verification Code + + + + + + + + + + + + + + + + +   + + + + diff --git a/templates/verification_code.txt b/templates/verification_code.txt index 6eed2ab..51551eb 100644 --- a/templates/verification_code.txt +++ b/templates/verification_code.txt @@ -4,7 +4,7 @@ Dear ${RECIPIENT_EMAIL}, ${CHALLENGE_CODE} - If you are not trying to login, please login and change your password. Someone maybe trying to + If you are not trying to login, please login and change your password. Someone may be trying to access your account illegally. Thank you! \ No newline at end of file diff --git a/test_scripts/curl/cli b/test_scripts/curl/cli index 55b10d3..b7ae5cd 100755 --- a/test_scripts/curl/cli +++ b/test_scripts/curl/cli @@ -175,7 +175,7 @@ listendpoints() { } getlogo() { - curl ${FLAGS} -X GET "https://${OWSEC}/wwwassets/open-wifi.svg" + curl ${FLAGS} -X GET "https://${OWSEC}/wwwassets/logo.png" } createuser() { diff --git a/wwwassets/open-wifi.svg b/wwwassets/open-wifi.svg deleted file mode 100644 index c27f346..0000000 --- a/wwwassets/open-wifi.svg +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -