mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 11:17:51 +00:00
Framework update + added modified to userrecord.
This commit is contained in:
@@ -423,6 +423,7 @@ namespace OpenWifi {
|
||||
}
|
||||
UInfo.userinfo.lastPasswordChange = std::time(nullptr);
|
||||
UInfo.userinfo.changePassword = false;
|
||||
UInfo.userinfo.modified = std::time(nullptr);
|
||||
StorageService()->UserDB().UpdateUserInfo(AUTHENTICATION_SYSTEM, UInfo.userinfo.id,UInfo.userinfo);
|
||||
}
|
||||
|
||||
@@ -468,6 +469,7 @@ namespace OpenWifi {
|
||||
}
|
||||
UInfo.userinfo.lastPasswordChange = std::time(nullptr);
|
||||
UInfo.userinfo.changePassword = false;
|
||||
UInfo.userinfo.modified = std::time(nullptr);
|
||||
StorageService()->SubDB().UpdateUserInfo(AUTHENTICATION_SYSTEM, UInfo.userinfo.id,UInfo.userinfo);
|
||||
}
|
||||
|
||||
@@ -560,6 +562,7 @@ namespace OpenWifi {
|
||||
A.id = MicroService::CreateUUID();
|
||||
A.created = std::time(nullptr);
|
||||
A.expires = A.created + 24*60*60;
|
||||
A.userAction = true;
|
||||
StorageService()->ActionLinksDB().CreateAction(A);
|
||||
UInfo.waitingForEmailCheck = true;
|
||||
return true;
|
||||
@@ -573,6 +576,7 @@ namespace OpenWifi {
|
||||
A.id = MicroService::CreateUUID();
|
||||
A.created = std::time(nullptr);
|
||||
A.expires = A.created + 24*60*60;
|
||||
A.userAction = false;
|
||||
StorageService()->ActionLinksDB().CreateAction(A);
|
||||
UInfo.waitingForEmailCheck = true;
|
||||
return true;
|
||||
|
||||
@@ -77,7 +77,9 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
SecurityObjects::UserInfo UInfo;
|
||||
if(!StorageService()->UserDB().GetUserById(Link.userId,UInfo)) {
|
||||
|
||||
bool Found = Link.userAction ? StorageService()->UserDB().GetUserById(Link.userId,UInfo) : StorageService()->SubDB().GetUserById(Link.userId,UInfo);
|
||||
if(!Found) {
|
||||
Poco::File FormFile{ Daemon()->AssetDir() + "/password_reset_error.html"};
|
||||
Types::StringPairVec FormVars{ {"UUID", Id},
|
||||
{"ERROR_TEXT", "This request does not contain a valid user ID. Please contact your system administrator."}};
|
||||
@@ -91,13 +93,20 @@ namespace OpenWifi {
|
||||
return SendHTMLFileBack(FormFile,FormVars);
|
||||
}
|
||||
|
||||
if(!AuthService()->SetPassword(Password1,UInfo)) {
|
||||
bool GoodPassword = Link.userAction ? AuthService()->SetPassword(Password1,UInfo) : AuthService()->SetSubPassword(Password1,UInfo);
|
||||
if(!GoodPassword) {
|
||||
Poco::File FormFile{ Daemon()->AssetDir() + "/password_reset_error.html"};
|
||||
Types::StringPairVec FormVars{ {"UUID", Id},
|
||||
{"ERROR_TEXT", "You cannot reuse one of your recent passwords."}};
|
||||
return SendHTMLFileBack(FormFile,FormVars);
|
||||
}
|
||||
StorageService()->UserDB().UpdateUserInfo(UInfo.email,Link.userId,UInfo);
|
||||
|
||||
UInfo.modified = std::time(nullptr);
|
||||
if(Link.userAction)
|
||||
StorageService()->UserDB().UpdateUserInfo(UInfo.email,Link.userId,UInfo);
|
||||
else
|
||||
StorageService()->SubDB().UpdateUserInfo(UInfo.email,Link.userId,UInfo);
|
||||
|
||||
Poco::File FormFile{ Daemon()->AssetDir() + "/password_reset_success.html"};
|
||||
Types::StringPairVec FormVars{ {"UUID", Id},
|
||||
{"USERNAME", UInfo.email},
|
||||
@@ -118,7 +127,8 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
SecurityObjects::UserInfo UInfo;
|
||||
if (!StorageService()->UserDB().GetUserById(Link.userId, UInfo)) {
|
||||
bool Found = Link.userAction ? StorageService()->UserDB().GetUserById(Link.userId,UInfo) : StorageService()->SubDB().GetUserById(Link.userId,UInfo);
|
||||
if (!Found) {
|
||||
Types::StringPairVec FormVars{{"UUID", Link.id},
|
||||
{"ERROR_TEXT", "This does not appear to be a valid email verification link.."}};
|
||||
Poco::File FormFile{Daemon()->AssetDir() + "/email_verification_error.html"};
|
||||
@@ -130,7 +140,11 @@ namespace OpenWifi {
|
||||
UInfo.validated = true;
|
||||
UInfo.lastEmailCheck = std::time(nullptr);
|
||||
UInfo.validationDate = std::time(nullptr);
|
||||
StorageService()->UserDB().UpdateUserInfo(UInfo.email, Link.userId, UInfo);
|
||||
UInfo.modified = std::time(nullptr);
|
||||
if(Link.userAction)
|
||||
StorageService()->UserDB().UpdateUserInfo(UInfo.email, Link.userId, UInfo);
|
||||
else
|
||||
StorageService()->SubDB().UpdateUserInfo(UInfo.email, Link.userId, UInfo);
|
||||
Types::StringPairVec FormVars{{"UUID", Link.id},
|
||||
{"USERNAME", UInfo.email},
|
||||
{"ACTION_LINK",MicroService::instance().GetUIURI()}};
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace OpenWifi {
|
||||
NewLink.userId = UInfo1.id;
|
||||
NewLink.created = std::time(nullptr);
|
||||
NewLink.expires = NewLink.created + (24*60*60);
|
||||
NewLink.userAction = true;
|
||||
StorageService()->ActionLinksDB().CreateAction(NewLink);
|
||||
|
||||
Poco::JSON::Object ReturnObj;
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace OpenWifi {
|
||||
NewLink.userId = UInfo1.id;
|
||||
NewLink.created = std::time(nullptr);
|
||||
NewLink.expires = NewLink.created + (24*60*60);
|
||||
NewLink.userAction = false;
|
||||
StorageService()->ActionLinksDB().CreateAction(NewLink);
|
||||
|
||||
Poco::JSON::Object ReturnObj;
|
||||
|
||||
@@ -498,6 +498,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"expires",expires);
|
||||
field_to_json(Obj,"completed",completed);
|
||||
field_to_json(Obj,"canceled",canceled);
|
||||
field_to_json(Obj,"userAction",userAction);
|
||||
}
|
||||
|
||||
bool ActionLink::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -514,6 +515,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"expires",expires);
|
||||
field_from_json(Obj,"completed",completed);
|
||||
field_from_json(Obj,"canceled",canceled);
|
||||
field_from_json(Obj,"userAction",userAction);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace OpenWifi {
|
||||
uint64_t expires=0;
|
||||
uint64_t completed=0;
|
||||
uint64_t canceled=0;
|
||||
bool userAction=true;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
"created bigint,"
|
||||
"expires bigint,"
|
||||
"completed bigint,"
|
||||
"canceled bigint"
|
||||
"canceled bigint,
|
||||
userAction boolean"
|
||||
*/
|
||||
|
||||
namespace OpenWifi {
|
||||
@@ -32,7 +33,8 @@ namespace OpenWifi {
|
||||
ORM::Field{"created", ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"expires", ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"completed", ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"canceled", ORM::FieldType::FT_BIGINT}
|
||||
ORM::Field{"canceled", ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"userAction", ORM::FieldType::FT_BOOLEAN}
|
||||
};
|
||||
|
||||
ActionLinkDB::ActionLinkDB(const std::string &Name, const std::string &ShortName, OpenWifi::DBType T,
|
||||
@@ -40,6 +42,16 @@ namespace OpenWifi {
|
||||
DB(T, Name.c_str(), ActionLinksDB_Fields,{}, P, L, ShortName.c_str()) {
|
||||
}
|
||||
|
||||
bool ActionLinkDB::Upgrade(uint32_t from, uint32_t &to) {
|
||||
std::vector<std::string> Statements{
|
||||
"alter table " + TableName_ + " add column userAction BOOLEAN default true;"
|
||||
};
|
||||
RunScript(Statements);
|
||||
to = 1;
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool ActionLinkDB::CreateAction( SecurityObjects::ActionLink & A) {
|
||||
return CreateRecord(A);
|
||||
}
|
||||
@@ -105,6 +117,7 @@ template<> void ORM::DB<OpenWifi::ActionLinkRecordTuple,
|
||||
U.expires = T.get<9>();
|
||||
U.completed = T.get<10>();
|
||||
U.canceled = T.get<11>();
|
||||
U.userAction = T.get<12>();
|
||||
}
|
||||
|
||||
template<> void ORM::DB<OpenWifi::ActionLinkRecordTuple,
|
||||
@@ -121,4 +134,5 @@ template<> void ORM::DB<OpenWifi::ActionLinkRecordTuple,
|
||||
T.set<9>(U.expires);
|
||||
T.set<10>(U.completed);
|
||||
T.set<11>(U.canceled);
|
||||
T.set<12>(U.userAction);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace OpenWifi {
|
||||
uint64_t, // created
|
||||
uint64_t, // expires
|
||||
uint64_t, // completed
|
||||
uint64_t // canceled
|
||||
uint64_t, // canceled
|
||||
bool // userAction
|
||||
> ActionLinkRecordTuple;
|
||||
typedef std::vector <ActionLinkRecordTuple> ActionLinkRecordTupleList;
|
||||
|
||||
@@ -38,6 +39,9 @@ namespace OpenWifi {
|
||||
bool GetActions(std::vector<SecurityObjects::ActionLink> &Links, uint64_t Max=200);
|
||||
void CleanOldActionLinks();
|
||||
|
||||
inline uint32_t Version() override { return 1;}
|
||||
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user