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:
@@ -80,7 +80,13 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||
}
|
||||
|
||||
if(!ACLProcessor::Can(UserInfo_.userinfo,NewUser,ACLProcessor::CREATE)) {
|
||||
Poco::toLowerInPlace(NewUser.email);
|
||||
SecurityObjects::UserInfo Existing;
|
||||
if(StorageService()->SubDB().GetUserByEmail(NewUser.email,Existing)) {
|
||||
return BadRequest(RESTAPI::Errors::UserAlreadyExists);
|
||||
}
|
||||
|
||||
if(!Internal_ && !ACLProcessor::Can(UserInfo_.userinfo,NewUser,ACLProcessor::CREATE)) {
|
||||
return UnAuthorized(RESTAPI::Errors::InsufficientAccessRights, ACCESS_DENIED);
|
||||
}
|
||||
|
||||
@@ -138,7 +144,7 @@ namespace OpenWifi {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if(!ACLProcessor::Can(UserInfo_.userinfo,Existing,ACLProcessor::MODIFY)) {
|
||||
if(!Internal_ && !ACLProcessor::Can(UserInfo_.userinfo,Existing,ACLProcessor::MODIFY)) {
|
||||
return UnAuthorized("Insufficient access rights.", ACCESS_DENIED);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::InvalidEmailAddress);
|
||||
}
|
||||
|
||||
SecurityObjects::UserInfo Existing;
|
||||
if(StorageService()->SubDB().GetUserByEmail(NewUser.email,Existing)) {
|
||||
return BadRequest(RESTAPI::Errors::UserAlreadyExists);
|
||||
}
|
||||
|
||||
if(!NewUser.currentPassword.empty()) {
|
||||
if(!AuthService()->ValidatePassword(NewUser.currentPassword)) {
|
||||
return BadRequest(RESTAPI::Errors::InvalidPassword);
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace OpenWifi::RESTAPI::Errors {
|
||||
static const std::string InvalidDeviceClass{"Invalid device class. Must be: any, venue, entity, or subscriber"};
|
||||
static const std::string SerialNumberAlreadyProvisioned{"This device has already been provisioned to a subscriber."};
|
||||
static const std::string SerialNumberNotTheProperClass{"Device is not available to subscribers. It ahs been assigned to another class of devices."};
|
||||
static const std::string UserAlreadyExists{"Username already exists."};
|
||||
}
|
||||
|
||||
namespace OpenWifi::RESTAPI::Protocol {
|
||||
|
||||
Reference in New Issue
Block a user