SPARK-1013 helper functions on the admin data
This commit is contained in:
1 parent
ed1b3aca92
commit
a444e71f70
3 files changed
+32
-13
No files matched your search
@@ -55,11 +55,13 @@ AdminServiceServer::AdminServiceServer(bts::api::ServiceContext& context)
|
||||
AdminServiceServer::~AdminServiceServer() {}
|
||||
|
||||
void AdminServiceServer::create_account(const api::admin::AccountCreateAPIArgument& acct_create_arg,
|
||||
const api::Response<::bts::api::VoidMessage>&)
|
||||
const api::Response<::bts::api::admin::PersistRequestResult>& reply)
|
||||
{
|
||||
bts::api::admin::PersistRequestResult result; result.set_is_success(true);
|
||||
if (AdminServiceUtils::find_account(_state, acct_create_arg.account_name())==nullptr){
|
||||
bts::api::admin::BTSAccount* new_account = _state.add_accounts();
|
||||
new_account->set_id(AdminServiceUtils::find_curr_acct_id(_state)+1);
|
||||
int new_account_id = AdminServiceUtils::find_curr_acct_id(_state)+1;
|
||||
new_account->set_id(new_account_id);
|
||||
if(acct_create_arg.has_parent_account_id())
|
||||
new_account->mutable_parent_account_id()->set_id(acct_create_arg.parent_account_id().id());
|
||||
new_account->set_name(acct_create_arg.account_name());
|
||||
@@ -67,6 +69,11 @@ void AdminServiceServer::create_account(const api::admin::AccountCreateAPIArgume
|
||||
new_account->set_is_active(false);
|
||||
_update_and_publish();
|
||||
}
|
||||
else{
|
||||
result.set_is_success(false);
|
||||
result.set_error_text("Account with this name already exists");
|
||||
}
|
||||
reply(result);
|
||||
}
|
||||
|
||||
void AdminServiceServer::set_account_clip_limits(const api::admin::AccountSecurityClipLimitsAPIArgument& acct_clips_arg,
|
||||
@@ -121,14 +128,25 @@ void AdminServiceServer::set_account_exchange_data(const api::admin::AccountExch
|
||||
}
|
||||
|
||||
void AdminServiceServer::create_user(const api::admin::UserCreateAPIArgument& new_user,
|
||||
const api::Response<::bts::api::VoidMessage>&)
|
||||
const api::Response<::bts::api::admin::PersistRequestResult>& reply)
|
||||
{
|
||||
bts::api::admin::BTSUser* new_user_ptr = _state.add_users();
|
||||
// test for name
|
||||
new_user_ptr->set_name(new_user.name());
|
||||
new_user_ptr->set_password (new_user.password());
|
||||
new_user_ptr->mutable_license_entitlements()->CopyFrom(new_user.license_entitlements());
|
||||
_update_and_publish();
|
||||
bts::api::admin::PersistRequestResult result; result.set_is_success(true);
|
||||
if (AdminServiceUtils::find_user (_state, new_user.name())){
|
||||
bts::api::admin::BTSUser* new_user_ptr = _state.add_users();
|
||||
int new_id = AdminServiceUtils::find_curr_user_id(_state) + 1;
|
||||
new_user_ptr->set_id(new_id);
|
||||
new_user_ptr->set_parent_group_id(new_user.parent_group_id());
|
||||
new_user_ptr->set_name(new_user.name());
|
||||
new_user_ptr->set_password (new_user.password());
|
||||
new_user_ptr->set_is_active(false);
|
||||
new_user_ptr->mutable_license_entitlements()->CopyFrom(new_user.license_entitlements());
|
||||
_update_and_publish();
|
||||
}
|
||||
else{
|
||||
result.set_is_success(false);
|
||||
result.set_error_text("User by this name already exists");
|
||||
}
|
||||
reply(result);
|
||||
}
|
||||
|
||||
void AdminServiceServer::set_user_account_association(const api::admin::UserAccountAssociationAPIArgument&,
|
||||
|
||||
Reference in new issue
Block a user