mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 19:27:59 +00:00
Fixing ActionLinks
This commit is contained in:
@@ -55,11 +55,17 @@ namespace OpenWifi {
|
||||
auto Password1 = Form.get("password1","bla");
|
||||
auto Password2 = Form.get("password1","blu");
|
||||
auto Id = Form.get("id","");
|
||||
auto Now = std::time(nullptr);
|
||||
|
||||
SecurityObjects::ActionLink Link;
|
||||
if(!StorageService()->GetActionLink(Id,Link))
|
||||
return DoReturnA404();
|
||||
|
||||
if(Now > Link.expires) {
|
||||
StorageService()->CancelAction(Id);
|
||||
return DoReturnA404();
|
||||
}
|
||||
|
||||
if(Password1!=Password2 || !AuthService()->ValidatePassword(Password2) || !AuthService()->ValidatePassword(Password1)) {
|
||||
Poco::File FormFile{ Daemon()->AssetDir() + "/password_reset_error.html"};
|
||||
Types::StringPairVec FormVars{ {"UUID", Id},
|
||||
@@ -96,6 +102,7 @@ namespace OpenWifi {
|
||||
Types::StringPairVec FormVars{ {"UUID", Id},
|
||||
{"USERNAME", UInfo.email},
|
||||
{"ACTION_LINK",MicroService::instance().GetUIURI()}};
|
||||
StorageService()->CompleteAction(Id);
|
||||
SendHTMLFileBack(FormFile,FormVars);
|
||||
} else {
|
||||
DoReturnA404();
|
||||
@@ -103,8 +110,14 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void RESTAPI_action_links::DoEmailVerification(SecurityObjects::ActionLink &Link) {
|
||||
SecurityObjects::UserInfo UInfo;
|
||||
auto Now = std::time(nullptr);
|
||||
|
||||
if(Now > Link.expires) {
|
||||
StorageService()->CancelAction(Link.id);
|
||||
return DoReturnA404();
|
||||
}
|
||||
|
||||
SecurityObjects::UserInfo UInfo;
|
||||
Logger_.information(Poco::format("EMAIL-VERIFICATION(%s): For ID=%s", Request->clientAddress().toString(), Link.userId));
|
||||
if (!StorageService()->GetUserByEmail(Link.userId, UInfo)) {
|
||||
Types::StringPairVec FormVars{{"UUID", Link.id},
|
||||
@@ -122,6 +135,7 @@ namespace OpenWifi {
|
||||
{"USERNAME", UInfo.email},
|
||||
{"ACTION_LINK",MicroService::instance().GetUIURI()}};
|
||||
Poco::File FormFile{Daemon()->AssetDir() + "/email_verification_success.html"};
|
||||
StorageService()->CompleteAction(Link.id);
|
||||
SendHTMLFileBack(FormFile, FormVars);
|
||||
}
|
||||
|
||||
|
||||
@@ -1726,7 +1726,7 @@ namespace OpenWifi {
|
||||
Response->set("Cache-Control", "private");
|
||||
Response->set("Pragma", "private");
|
||||
Response->set("Expires", "Mon, 26 Jul 2027 05:00:00 GMT");
|
||||
Response->set("Content-Length", std::to_string(File.getSize()));
|
||||
Response->setContentLength(File.getSize());
|
||||
AddCORS();
|
||||
Response->sendFile(File.path(),"application/octet-stream");
|
||||
}
|
||||
@@ -1766,7 +1766,7 @@ namespace OpenWifi {
|
||||
Response->set("Expires", "Mon, 26 Jul 2027 05:00:00 GMT");
|
||||
std::string FormContent = Utils::LoadFile(File.path());
|
||||
Utils::ReplaceVariables(FormContent, FormVars);
|
||||
Response->set("Content-Length", std::to_string(FormContent.size()));
|
||||
Response->setContentLength(FormContent.size());
|
||||
AddCORS();
|
||||
Response->setChunkedTransferEncoding(true);
|
||||
Response->setContentType("text/html");
|
||||
@@ -3275,7 +3275,8 @@ namespace OpenWifi {
|
||||
auto InsertResult = CertNames.insert(CertFileName);
|
||||
if(InsertResult.second) {
|
||||
Poco::JSON::Object Inner;
|
||||
Inner.set("filename", CertFileName);
|
||||
Poco::Path F(CertFileName);
|
||||
Inner.set("filename", F.getFileName());
|
||||
Poco::Crypto::X509Certificate C(CertFileName);
|
||||
auto ExpiresOn = C.expiresOn();
|
||||
Inner.set("expiresOn",ExpiresOn.timestamp().epochTime());
|
||||
|
||||
@@ -69,9 +69,9 @@ namespace OpenWifi {
|
||||
|
||||
ActionLinkRecordList ARL;
|
||||
|
||||
std::string St2{
|
||||
"SELECT " + AllActionLinksFieldsForSelect + " From ActionLinks where sent=0 and canceled=0"};
|
||||
Select << ConvertParams(St2),
|
||||
std::string S{
|
||||
"SELECT " + AllActionLinksFieldsForSelect + " From ActionLinks where sent=0 and canceled=0 and completed=0"};
|
||||
Select << ConvertParams(S),
|
||||
Poco::Data::Keywords::into(ARL);
|
||||
Select.execute();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user