Adding password web password reset

This commit is contained in:
stephb9959
2021-07-10 11:29:30 -07:00
parent e4f15b3d4b
commit 5793c80a34
20 changed files with 515 additions and 11 deletions

View File

@@ -21,6 +21,8 @@
#include "Poco/Logger.h"
#include "Poco/Message.h"
#include "Poco/File.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "uCentralProtocol.h"
#include "Daemon.h"
@@ -399,4 +401,46 @@ namespace uCentral::Utils {
// try to match the string with the regular expression
return std::regex_match(email, pattern);
}
std::string LoadFile( const Poco::File & F) {
std::string Result;
try {
std::ostringstream OS;
std::ifstream IF(F.path());
Poco::StreamCopier::copyStream(IF, OS);
Result = OS.str();
} catch (...) {
}
return Result;
}
void ReplaceVariables( std::string & Content , const Types::StringPairVec & P) {
for(const auto &[Variable,Value]:P) {
Poco::replaceInPlace(Content,"${" + Variable + "}", Value);
}
}
std::string FindMediaType(const Poco::File &F) {
Poco::Path P(F.path());
const auto E = P.getExtension();
if(E=="png")
return "image/png";
if(E=="gif")
return "image/gif";
if(E=="jpeg")
return "image/jpeg";
if(E=="jpg")
return "image/jpeg";
if(E=="svg")
return "image/svg";
if(E=="html")
return "text/html";
if(E=="css")
return "text/css";
if(E=="js")
return "application/javascript";
return "application/octet-stream";
}
}