mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Adding new registration processing for signup.
This commit is contained in:
@@ -1048,6 +1048,9 @@ components:
|
||||
userId:
|
||||
type: string
|
||||
format: uuid
|
||||
operatorId:
|
||||
type: string
|
||||
format: uuid
|
||||
macAddress:
|
||||
type: string
|
||||
serialNumber:
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenWifi{
|
||||
return BadRequest(RESTAPI::Errors::NameMustBeSet);
|
||||
}
|
||||
|
||||
if(NewObject.entity.empty() || !StorageService()->EntityDB().Exists("id",NewObject.entity)) {
|
||||
if(NewObject.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObject.entity)) {
|
||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,12 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::InvalidRegistrationOperatorName);
|
||||
}
|
||||
|
||||
// find the operator id
|
||||
ProvObjects::Operator SignupOperator;
|
||||
if(!StorageService()->OperatorDB().GetRecord("registrationId", registrationId, SignupOperator)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidRegistrationOperatorName);
|
||||
}
|
||||
|
||||
// if a signup already exists for this user, we should just return its value completion
|
||||
SignupDB::RecordVec SEs;
|
||||
if(StorageService()->SignupDB().GetRecords(0,100, SEs, " email='" + UserName + "' and serialNumber='"+macAddress+"' ")) {
|
||||
@@ -113,6 +119,7 @@ namespace OpenWifi {
|
||||
SE.deviceID = deviceID;
|
||||
SE.registrationId = registrationId;
|
||||
SE.status = "waiting-for-email-verification";
|
||||
SE.operatorId = SignupOperator.info.id;
|
||||
SE.statusCode = ProvObjects::SignupStatusCodes::SignupWaitingForEmail;
|
||||
StorageService()->SignupDB().CreateRecord(SE);
|
||||
Signup()->AddOutstandingSignup(SE);
|
||||
|
||||
@@ -896,6 +896,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"statusCode", statusCode);
|
||||
field_to_json( Obj,"deviceID", deviceID);
|
||||
field_to_json( Obj,"registrationId",registrationId);
|
||||
field_to_json( Obj,"operatorId",operatorId);
|
||||
}
|
||||
|
||||
bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -912,6 +913,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"statusCode", statusCode);
|
||||
field_from_json( Obj,"deviceID", deviceID);
|
||||
field_from_json( Obj,"registrationId",registrationId);
|
||||
field_from_json( Obj,"operatorId",operatorId);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
|
||||
@@ -534,6 +534,7 @@ namespace OpenWifi::ProvObjects {
|
||||
uint64_t statusCode=0;
|
||||
std::string deviceID;
|
||||
std::string registrationId;
|
||||
std::string operatorId;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
@@ -85,10 +85,18 @@ namespace OpenWifi {
|
||||
|
||||
// we need to move this device to the SubscriberDevice DB
|
||||
ProvObjects::SubscriberDevice SD;
|
||||
SD.info.id = MicroService::CreateUUID();
|
||||
SD.info.modified = SD.info.created = OpenWifi::Now();
|
||||
SD.info.name = IT.realMacAddress;
|
||||
SD.operatorId = SE.operatorId;
|
||||
SD.serialNumber = SerialNumber;
|
||||
SD.realMacAddress = SE.macAddress;
|
||||
SD.locale = IT.locale;
|
||||
SD.deviceType = IT.deviceType;
|
||||
SD.state = OS.str();
|
||||
SD.subscriberId = SE.userId;
|
||||
StorageService()->SubscriberDeviceDB().DeleteRecord("serialNumber", SD.serialNumber);
|
||||
StorageService()->SubscriberDeviceDB().CreateRecord(SD);
|
||||
|
||||
SE.status = "signup completed";
|
||||
SE.serialNumber = SerialNumber;
|
||||
|
||||
@@ -31,18 +31,19 @@ namespace OpenWifi {
|
||||
ORM::Field{"statusCode",ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"macAddress",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"deviceID",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"registrationId",ORM::FieldType::FT_TEXT}
|
||||
ORM::Field{"registrationId",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"operatorId",ORM::FieldType::FT_TEXT}
|
||||
};
|
||||
|
||||
const static ORM::IndexVec SignupDB_Indexes{
|
||||
{ std::string("signup4_email_index"),
|
||||
{ std::string("signup5_email_index"),
|
||||
ORM::IndexEntryVec{
|
||||
{std::string("email"),
|
||||
ORM::Indextype::ASC} } }
|
||||
};
|
||||
|
||||
SignupDB::SignupDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept :
|
||||
DB(T, "signups4", SignupDB_Fields, SignupDB_Indexes, P, L, "sig") {
|
||||
DB(T, "signups5", SignupDB_Fields, SignupDB_Indexes, P, L, "sig") {
|
||||
}
|
||||
|
||||
bool SignupDB::GetIncompleteSignups(SignupDB::RecordVec &Signups) {
|
||||
@@ -137,6 +138,7 @@ template<> void ORM::DB< OpenWifi::SignupDBRecordType, OpenWifi::ProvObjects:
|
||||
Out.macAddress = In.get<14>();
|
||||
Out.deviceID = In.get<15>();
|
||||
Out.registrationId = In.get<16>();
|
||||
Out.operatorId = In.get<17>();
|
||||
}
|
||||
|
||||
template<> void ORM::DB< OpenWifi::SignupDBRecordType, OpenWifi::ProvObjects::SignupEntry>::Convert(const OpenWifi::ProvObjects::SignupEntry &In, OpenWifi::SignupDBRecordType &Out) {
|
||||
@@ -157,4 +159,5 @@ template<> void ORM::DB< OpenWifi::SignupDBRecordType, OpenWifi::ProvObjects:
|
||||
Out.set<14>(In.macAddress);
|
||||
Out.set<15>(In.deviceID);
|
||||
Out.set<16>(In.registrationId);
|
||||
Out.set<17>(In.operatorId);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenWifi {
|
||||
uint64_t,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string
|
||||
> SignupDBRecordType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user