mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-31 18:57:51 +00:00
Fixing submfa method
This commit is contained in:
@@ -31,6 +31,7 @@ namespace OpenWifi {
|
||||
NotFound();
|
||||
}
|
||||
|
||||
#define DBGLINE std::cout << __FILE__ << " : " << __LINE__ << std::endl;
|
||||
void RESTAPI_submfa_handler::DoPut() {
|
||||
|
||||
std::cout << "DoPut..." << std::endl;
|
||||
@@ -38,11 +39,15 @@ namespace OpenWifi {
|
||||
auto Body = ParseStream();
|
||||
SecurityObjects::SubMfaConfig MFC;
|
||||
|
||||
DBGLINE
|
||||
|
||||
if(!MFC.from_json(Body)) {
|
||||
DBGLINE
|
||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||
}
|
||||
|
||||
if(MFC.type=="disabled") {
|
||||
DBGLINE
|
||||
SecurityObjects::UserInfo User;
|
||||
StorageService()->GetUserById(UserInfo_.userinfo.Id,User);
|
||||
User.userTypeProprietaryInfo.mfa.enabled = false;
|
||||
@@ -50,8 +55,10 @@ namespace OpenWifi {
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
MFC.to_json(Answer);
|
||||
DBGLINE
|
||||
return ReturnObject(Answer);
|
||||
} else if (MFC.type=="email") {
|
||||
DBGLINE
|
||||
SecurityObjects::UserInfo User;
|
||||
|
||||
StorageService()->GetUserById(UserInfo_.userinfo.Id,User);
|
||||
@@ -61,28 +68,36 @@ namespace OpenWifi {
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
MFC.to_json(Answer);
|
||||
DBGLINE
|
||||
return ReturnObject(Answer);
|
||||
} else if (MFC.type=="sms") {
|
||||
DBGLINE
|
||||
if(GetBoolParameter("startValidation",false)) {
|
||||
DBGLINE
|
||||
if(MFC.sms.empty()) {
|
||||
return BadRequest("Missing phone number");
|
||||
}
|
||||
DBGLINE
|
||||
|
||||
if(SMSSender()->StartValidation(MFC.sms, UserInfo_.userinfo.email)) {
|
||||
return OK();
|
||||
} else {
|
||||
return InternalError("SMS could not be sent. Verify the number or try again later.");
|
||||
}
|
||||
DBGLINE
|
||||
} else if(GetBoolParameter("completeValidation",false)) {
|
||||
auto ChallengeCode = GetParameter("challengeCode","");
|
||||
if(ChallengeCode.empty()) {
|
||||
DBGLINE
|
||||
return BadRequest("Missing 'challengeCode'");
|
||||
}
|
||||
if(MFC.sms.empty()) {
|
||||
DBGLINE
|
||||
return BadRequest("Missing phone number");
|
||||
}
|
||||
if(SMSSender()->CompleteValidation(MFC.sms, ChallengeCode, UserInfo_.userinfo.email)) {
|
||||
SecurityObjects::UserInfo User;
|
||||
DBGLINE
|
||||
|
||||
StorageService()->GetUserById(UserInfo_.userinfo.Id,User);
|
||||
User.userTypeProprietaryInfo.mfa.method = "sms";
|
||||
@@ -99,10 +114,12 @@ namespace OpenWifi {
|
||||
MFC.to_json(Answer);
|
||||
return ReturnObject(Answer);
|
||||
} else {
|
||||
DBGLINE
|
||||
return InternalError("SMS could not be sent. Verify the number or try again later.");
|
||||
}
|
||||
}
|
||||
}
|
||||
DBGLINE
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user