mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Adding signup registrationId
This commit is contained in:
@@ -1066,6 +1066,10 @@ components:
|
||||
statusCode:
|
||||
type: integer
|
||||
format: int64
|
||||
registrationId:
|
||||
type: string
|
||||
minLength: 4
|
||||
maxLength: 16
|
||||
|
||||
Variable:
|
||||
type: object
|
||||
@@ -1209,6 +1213,10 @@ components:
|
||||
$ref: '#/components/schemas/ManagementRoleList'
|
||||
sourceIP:
|
||||
$ref: '#/components/schemas/StringList'
|
||||
registrationId:
|
||||
type: string
|
||||
minLength: 4
|
||||
maxLength: 16
|
||||
|
||||
OperatorList:
|
||||
type: object
|
||||
@@ -3314,6 +3322,11 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
required: false
|
||||
- in: query
|
||||
name: registrationId
|
||||
schema:
|
||||
type: string
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
$ref: '#/components/schemas/SignupEntry'
|
||||
|
||||
@@ -76,11 +76,15 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::InvalidIPAddresses);
|
||||
}
|
||||
|
||||
Poco::toLowerInPlace(NewObject.registrationId);
|
||||
if(NewObject.registrationId.empty() || DB_.Exists("registrationId",NewObject.registrationId)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidRegistrationOperatorName);
|
||||
}
|
||||
|
||||
ProvObjects::CreateObjectInfo(RawObject, UserInfo_.userinfo, NewObject.info);
|
||||
if(DB_.CreateRecord(NewObject)) {
|
||||
|
||||
// Create the default service...
|
||||
|
||||
ProvObjects::ServiceClass DefSer;
|
||||
DefSer.info.id = MicroService::CreateUUID();
|
||||
DefSer.info.name = "Default Service Class";
|
||||
|
||||
@@ -9,13 +9,15 @@
|
||||
namespace OpenWifi {
|
||||
|
||||
void RESTAPI_signup_handler::DoPost() {
|
||||
auto UserName = GetParameter("email","");
|
||||
auto UserName = GetParameter("email");
|
||||
Poco::toLowerInPlace(UserName);
|
||||
auto macAddress = GetParameter("macAddress","");
|
||||
auto macAddress = GetParameter("macAddress");
|
||||
Poco::toLowerInPlace(macAddress);
|
||||
auto deviceID = GetParameter("deviceID","");
|
||||
auto deviceID = GetParameter("deviceID");
|
||||
auto registrationId = GetParameter("registrationId");
|
||||
Poco::toLowerInPlace(registrationId);
|
||||
|
||||
if(UserName.empty() || macAddress.empty()) {
|
||||
if(UserName.empty() || macAddress.empty() || registrationId.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
@@ -27,6 +29,10 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::InvalidSerialNumber);
|
||||
}
|
||||
|
||||
if(registrationId.empty()) {
|
||||
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+"' ")) {
|
||||
@@ -47,6 +53,10 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
|
||||
if(!StorageService()->OperatorDB().Exists("registrationId",registrationId)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidRegistrationOperatorName);
|
||||
}
|
||||
|
||||
// So we do not have an outstanding signup...
|
||||
// Can we actually claim this serial number??? if not, we need to return an error
|
||||
ProvObjects::InventoryTag IT;
|
||||
@@ -101,6 +111,7 @@ namespace OpenWifi {
|
||||
SE.userId = UI.id;
|
||||
SE.email = UserName;
|
||||
SE.deviceID = deviceID;
|
||||
SE.registrationId = registrationId;
|
||||
SE.status = "waiting-for-email-verification";
|
||||
SE.statusCode = ProvObjects::SignupStatusCodes::SignupWaitingForEmail;
|
||||
StorageService()->SignupDB().CreateRecord(SE);
|
||||
@@ -133,8 +144,8 @@ namespace OpenWifi {
|
||||
|
||||
// this will be called by the SEC backend once the password has been verified.
|
||||
void RESTAPI_signup_handler::DoPut() {
|
||||
auto SignupUUID = GetParameter("signupUUID","");
|
||||
auto Operation = GetParameter("operation","");
|
||||
auto SignupUUID = GetParameter("signupUUID");
|
||||
auto Operation = GetParameter("operation");
|
||||
|
||||
if(SignupUUID.empty() || Operation.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
@@ -161,9 +172,9 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void RESTAPI_signup_handler::DoGet() {
|
||||
auto EMail = GetParameter("email", "");
|
||||
auto SignupUUID = GetParameter("signupUUID", "");
|
||||
auto macAddress = GetParameter("macAddress", "");
|
||||
auto EMail = GetParameter("email");
|
||||
auto SignupUUID = GetParameter("signupUUID");
|
||||
auto macAddress = GetParameter("macAddress");
|
||||
auto List = GetBoolParameter("listOnly",false);
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
|
||||
@@ -203,6 +203,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"variables",variables);
|
||||
field_to_json( Obj,"defaultOperator",defaultOperator);
|
||||
field_to_json( Obj,"sourceIP",sourceIP);
|
||||
field_to_json( Obj,"registrationId",registrationId);
|
||||
}
|
||||
|
||||
bool Operator::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -216,6 +217,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"variables",variables);
|
||||
field_from_json( Obj,"defaultOperator",defaultOperator);
|
||||
field_from_json( Obj,"sourceIP",sourceIP);
|
||||
field_from_json( Obj,"registrationId",registrationId);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
@@ -893,6 +895,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"error", error);
|
||||
field_to_json( Obj,"statusCode", statusCode);
|
||||
field_to_json( Obj,"deviceID", deviceID);
|
||||
field_to_json( Obj,"registrationId",registrationId);
|
||||
}
|
||||
|
||||
bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -908,6 +911,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"error", error);
|
||||
field_from_json( Obj,"statusCode", statusCode);
|
||||
field_from_json( Obj,"deviceID", deviceID);
|
||||
field_from_json( Obj,"registrationId",registrationId);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
|
||||
@@ -533,6 +533,7 @@ namespace OpenWifi::ProvObjects {
|
||||
uint64_t error=0;
|
||||
uint64_t statusCode=0;
|
||||
std::string deviceID;
|
||||
std::string registrationId;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -586,6 +587,7 @@ namespace OpenWifi::ProvObjects {
|
||||
std::vector<Variable> variables;
|
||||
bool defaultOperator=false;
|
||||
Types::StringVec sourceIP;
|
||||
std::string registrationId;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
@@ -83,6 +83,13 @@ namespace OpenWifi {
|
||||
IT.state = OS.str();
|
||||
StorageService()->InventoryDB().UpdateRecord("id", IT.info.id, IT);
|
||||
|
||||
// we need to move this device to the SubscriberDevice DB
|
||||
ProvObjects::SubscriberDevice SD;
|
||||
SD.serialNumber = SerialNumber;
|
||||
SD.realMacAddress = SE.macAddress;
|
||||
SD.locale = IT.locale;
|
||||
SD.deviceType = IT.deviceType;
|
||||
|
||||
SE.status = "signup completed";
|
||||
SE.serialNumber = SerialNumber;
|
||||
SE.statusCode = ProvObjects::SignupStatusCodes::SignupSuccess;
|
||||
|
||||
@@ -91,14 +91,17 @@ namespace OpenWifi::RESTAPI::Errors {
|
||||
static const std::string InvalidIPAddresses{"Invalid IP addresses."};
|
||||
static const std::string InvalidBillingCode{"Empty of invalid billing code."};
|
||||
static const std::string InvalidBillingPeriod{"Invalid billing period."};
|
||||
static const std::string InvalidSubscriberId{"Invalid subscriber ID"};
|
||||
static const std::string InvalidContactId{"Invalid contact ID"};
|
||||
static const std::string InvalidLocationId{"Invalid location ID"};
|
||||
static const std::string InvalidContactType{"Invalid contact type"};
|
||||
static const std::string InvalidLocationType{"Invalid location type"};
|
||||
static const std::string InvalidOperatorId{"Invalid operator ID"};
|
||||
static const std::string InvalidServiceClassId{"Invalid service class ID"};
|
||||
static const std::string InvalidSubscriberDeviceId{"Invalid subscriber device ID"};
|
||||
static const std::string InvalidSubscriberId{"Invalid subscriber ID."};
|
||||
static const std::string InvalidContactId{"Invalid contact ID."};
|
||||
static const std::string InvalidLocationId{"Invalid location ID."};
|
||||
static const std::string InvalidContactType{"Invalid contact type."};
|
||||
static const std::string InvalidLocationType{"Invalid location type."};
|
||||
static const std::string InvalidOperatorId{"Invalid operator ID."};
|
||||
static const std::string InvalidServiceClassId{"Invalid service class ID."};
|
||||
static const std::string InvalidSubscriberDeviceId{"Invalid subscriber device ID."};
|
||||
static const std::string InvalidRegistrationOperatorId{"Invalid registration operator ID."};
|
||||
static const std::string InvalidRegistrationOperatorName{"Invalid registration operator name."};
|
||||
static const std::string RegistrationNameDuplicate{"Registration name must be unique."};
|
||||
}
|
||||
|
||||
namespace OpenWifi::RESTAPI::Protocol {
|
||||
|
||||
@@ -25,18 +25,19 @@ namespace OpenWifi {
|
||||
ORM::Field{"firmwareRCOnly",ORM::FieldType::FT_BOOLEAN},
|
||||
ORM::Field{"variables",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"defaultOperator",ORM::FieldType::FT_BOOLEAN},
|
||||
ORM::Field{"sourceIP",ORM::FieldType::FT_TEXT}
|
||||
ORM::Field{"sourceIP",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"registrationId",ORM::FieldType::FT_TEXT}
|
||||
};
|
||||
|
||||
static ORM::IndexVec OperatorDB_Indexes{
|
||||
{ std::string("operator_name_index"),
|
||||
{ std::string("operator2_name_index"),
|
||||
ORM::IndexEntryVec{
|
||||
{std::string("name"),
|
||||
ORM::Indextype::ASC} } }
|
||||
};
|
||||
|
||||
OperatorDB::OperatorDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||
DB(T, "operators", OperatorDB_Fields, OperatorDB_Indexes, P, L, "opr") {
|
||||
DB(T, "operators2", OperatorDB_Fields, OperatorDB_Indexes, P, L, "opr") {
|
||||
}
|
||||
|
||||
bool OperatorDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
|
||||
@@ -85,6 +86,7 @@ template<> void ORM::DB< OpenWifi::OperatorDBRecordType, OpenWifi::ProvObject
|
||||
Out.variables = OpenWifi::RESTAPI_utils::to_object_array<OpenWifi::ProvObjects::Variable>(In.get<11>());
|
||||
Out.defaultOperator = In.get<12>();
|
||||
Out.sourceIP = OpenWifi::RESTAPI_utils::to_object_array(In.get<13>());
|
||||
Out.registrationId = In.get<14>();
|
||||
}
|
||||
|
||||
template<> void ORM::DB< OpenWifi::OperatorDBRecordType, OpenWifi::ProvObjects::Operator>::Convert(const OpenWifi::ProvObjects::Operator &In, OpenWifi::OperatorDBRecordType &Out) {
|
||||
@@ -102,4 +104,5 @@ template<> void ORM::DB< OpenWifi::OperatorDBRecordType, OpenWifi::ProvObject
|
||||
Out.set<11>(OpenWifi::RESTAPI_utils::to_string(In.variables));
|
||||
Out.set<12>(In.defaultOperator);
|
||||
Out.set<13>(OpenWifi::RESTAPI_utils::to_string(In.sourceIP));
|
||||
Out.set<14>(In.registrationId);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace OpenWifi {
|
||||
bool,
|
||||
std::string,
|
||||
bool,
|
||||
std::string,
|
||||
std::string
|
||||
> OperatorDBRecordType;
|
||||
|
||||
|
||||
@@ -30,18 +30,19 @@ namespace OpenWifi {
|
||||
ORM::Field{"error",ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"statusCode",ORM::FieldType::FT_BIGINT},
|
||||
ORM::Field{"macAddress",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"deviceID",ORM::FieldType::FT_TEXT}
|
||||
ORM::Field{"deviceID",ORM::FieldType::FT_TEXT},
|
||||
ORM::Field{"registrationId",ORM::FieldType::FT_TEXT}
|
||||
};
|
||||
|
||||
const static ORM::IndexVec SignupDB_Indexes{
|
||||
{ std::string("signup_email_index"),
|
||||
{ std::string("signup4_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, "signups3", SignupDB_Fields, SignupDB_Indexes, P, L, "sig") {
|
||||
DB(T, "signups4", SignupDB_Fields, SignupDB_Indexes, P, L, "sig") {
|
||||
}
|
||||
|
||||
bool SignupDB::GetIncompleteSignups(SignupDB::RecordVec &Signups) {
|
||||
@@ -135,6 +136,7 @@ template<> void ORM::DB< OpenWifi::SignupDBRecordType, OpenWifi::ProvObjects:
|
||||
Out.statusCode = In.get<13>();
|
||||
Out.macAddress = In.get<14>();
|
||||
Out.deviceID = In.get<15>();
|
||||
Out.registrationId = In.get<16>();
|
||||
}
|
||||
|
||||
template<> void ORM::DB< OpenWifi::SignupDBRecordType, OpenWifi::ProvObjects::SignupEntry>::Convert(const OpenWifi::ProvObjects::SignupEntry &In, OpenWifi::SignupDBRecordType &Out) {
|
||||
@@ -154,4 +156,5 @@ template<> void ORM::DB< OpenWifi::SignupDBRecordType, OpenWifi::ProvObjects:
|
||||
Out.set<13>(In.statusCode);
|
||||
Out.set<14>(In.macAddress);
|
||||
Out.set<15>(In.deviceID);
|
||||
Out.set<16>(In.registrationId);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace OpenWifi {
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string
|
||||
> SignupDBRecordType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user