mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-05 05:07:51 +00:00
Adding Subscriber Signup.
This commit is contained in:
@@ -13,39 +13,32 @@ namespace OpenWifi {
|
||||
|
||||
auto UserName = GetParameter("email","");
|
||||
auto signupUUID = GetParameter("signupUUID","");
|
||||
__DBG__
|
||||
if(UserName.empty() || signupUUID.empty()) {
|
||||
__DBG__
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
if(!Utils::ValidEMailAddress(UserName)) {
|
||||
__DBG__
|
||||
return BadRequest(RESTAPI::Errors::InvalidEmailAddress);
|
||||
}
|
||||
|
||||
// Do we already exist? Can only signup once...
|
||||
SecurityObjects::UserInfo Existing;
|
||||
if(StorageService()->SubDB().GetUserByEmail(UserName,Existing)) {
|
||||
__DBG__
|
||||
|
||||
if(Existing.signingUp.empty()) {
|
||||
__DBG__
|
||||
return BadRequest(1, "Subscriber already signed up.");
|
||||
}
|
||||
|
||||
if(Existing.waitingForEmailCheck) {
|
||||
__DBG__
|
||||
return BadRequest(2, "Waiting for email check completion.");
|
||||
}
|
||||
|
||||
__DBG__
|
||||
return BadRequest(3, "Waiting for device:" + Existing.signingUp);
|
||||
}
|
||||
|
||||
SecurityObjects::UserInfo NewSub;
|
||||
NewSub.signingUp = signupUUID;
|
||||
NewSub.waitingForEmailCheck = true;
|
||||
NewSub.name = UserName;
|
||||
NewSub.modified = std::time(nullptr);
|
||||
NewSub.creationDate = std::time(nullptr);
|
||||
NewSub.id = MicroService::instance().CreateUUID();
|
||||
@@ -53,9 +46,7 @@ namespace OpenWifi {
|
||||
NewSub.userRole = SecurityObjects::SUBSCRIBER;
|
||||
NewSub.changePassword = true;
|
||||
|
||||
__DBG__
|
||||
StorageService()->SubDB().CreateRecord(NewSub);
|
||||
__DBG__
|
||||
|
||||
Logger_.information(Poco::format("SIGNUP-PASSWORD(%s): Request for %s", Request->clientAddress().toString(), UserName));
|
||||
SecurityObjects::ActionLink NewLink;
|
||||
@@ -67,9 +58,10 @@ namespace OpenWifi {
|
||||
NewLink.expires = NewLink.created + (1*60*60); // 1 hour
|
||||
NewLink.userAction = false;
|
||||
StorageService()->ActionLinksDB().CreateAction(NewLink);
|
||||
__DBG__
|
||||
|
||||
return OK();
|
||||
Poco::JSON::Object Answer;
|
||||
NewSub.to_json(Answer);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
|
||||
void RESTAPI_signup_handler::DoPut() {
|
||||
|
||||
Reference in New Issue
Block a user