mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-02 03:37:51 +00:00
Signup
This commit is contained in:
@@ -6,33 +6,40 @@
|
|||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
|
|
||||||
|
#define __DBG__ std::cout << __LINE__ << std::endl;
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
void RESTAPI_signup_handler::DoPost() {
|
void RESTAPI_signup_handler::DoPost() {
|
||||||
|
|
||||||
auto UserName = GetParameter("email","");
|
auto UserName = GetParameter("email","");
|
||||||
auto signupUUID = GetParameter("signupUUID","");
|
auto signupUUID = GetParameter("signupUUID","");
|
||||||
|
__DBG__
|
||||||
if(UserName.empty() || signupUUID.empty()) {
|
if(UserName.empty() || signupUUID.empty()) {
|
||||||
|
__DBG__
|
||||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utils::ValidEMailAddress(UserName)) {
|
if(!Utils::ValidEMailAddress(UserName)) {
|
||||||
|
__DBG__
|
||||||
return BadRequest(RESTAPI::Errors::InvalidEmailAddress);
|
return BadRequest(RESTAPI::Errors::InvalidEmailAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we already exist? Can only signup once...
|
// Do we already exist? Can only signup once...
|
||||||
SecurityObjects::UserInfo Existing;
|
SecurityObjects::UserInfo Existing;
|
||||||
if(StorageService()->SubDB().GetUserByEmail(UserName,Existing)) {
|
if(StorageService()->SubDB().GetUserByEmail(UserName,Existing)) {
|
||||||
|
__DBG__
|
||||||
|
|
||||||
if(Existing.signingUp.empty()) {
|
if(Existing.signingUp.empty()) {
|
||||||
|
__DBG__
|
||||||
return BadRequest(1, "Subscriber already signed up.");
|
return BadRequest(1, "Subscriber already signed up.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Existing.waitingForEmailCheck) {
|
if(Existing.waitingForEmailCheck) {
|
||||||
|
__DBG__
|
||||||
return BadRequest(2, "Waiting for email check completion.");
|
return BadRequest(2, "Waiting for email check completion.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__DBG__
|
||||||
return BadRequest(3, "Waiting for device:" + Existing.signingUp);
|
return BadRequest(3, "Waiting for device:" + Existing.signingUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +53,9 @@ namespace OpenWifi {
|
|||||||
NewSub.userRole = SecurityObjects::SUBSCRIBER;
|
NewSub.userRole = SecurityObjects::SUBSCRIBER;
|
||||||
NewSub.changePassword = true;
|
NewSub.changePassword = true;
|
||||||
|
|
||||||
|
__DBG__
|
||||||
StorageService()->SubDB().CreateRecord(NewSub);
|
StorageService()->SubDB().CreateRecord(NewSub);
|
||||||
|
__DBG__
|
||||||
|
|
||||||
Logger_.information(Poco::format("SIGNUP-PASSWORD(%s): Request for %s", Request->clientAddress().toString(), UserName));
|
Logger_.information(Poco::format("SIGNUP-PASSWORD(%s): Request for %s", Request->clientAddress().toString(), UserName));
|
||||||
SecurityObjects::ActionLink NewLink;
|
SecurityObjects::ActionLink NewLink;
|
||||||
@@ -58,6 +67,7 @@ namespace OpenWifi {
|
|||||||
NewLink.expires = NewLink.created + (1*60*60); // 1 hour
|
NewLink.expires = NewLink.created + (1*60*60); // 1 hour
|
||||||
NewLink.userAction = false;
|
NewLink.userAction = false;
|
||||||
StorageService()->ActionLinksDB().CreateAction(NewLink);
|
StorageService()->ActionLinksDB().CreateAction(NewLink);
|
||||||
|
__DBG__
|
||||||
|
|
||||||
return OK();
|
return OK();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user