7 const std::vector<name>& disallow_perms) {
10 sysio::check(allow_perms.empty() || disallow_perms.empty(),
"either allow_perms or disallow_perms must be empty");
11 sysio::check(allow_perms.empty() ||
12 std::find(allow_perms.begin(), allow_perms.end(),
"owner"_n) != allow_perms.end(),
13 "allow_perms does not contain owner");
14 sysio::check(disallow_perms.empty() ||
15 std::find(disallow_perms.begin(), disallow_perms.end(),
"owner"_n) == disallow_perms.end(),
16 "disallow_perms contains owner");
17 auto it = table.find(account.value);
18 if(!allow_perms.empty() || !disallow_perms.empty()) {
19 if(it == table.end()) {
20 table.emplace(account, [&](
auto& row){
21 row.account = account;
22 row.allow_perms = allow_perms;
23 row.disallow_perms = disallow_perms;
26 table.modify(it, account, [&](
auto& row){
27 row.allow_perms = allow_perms;
28 row.disallow_perms = disallow_perms;
38 name by(authorized_by.has_value() ? authorized_by.value().value : 0);
40 sysio::require_auth({account, by});
42 auto it = table.find(account.value);
45 sysio::check(by.value,
"authorized_by is required for this account");
46 if(!it->allow_perms.empty())
48 std::find(it->allow_perms.begin(), it->allow_perms.end(), by) != it->allow_perms.end(),
49 "authorized_by does not appear in allow_perms");
52 std::find(it->disallow_perms.begin(), it->disallow_perms.end(), by) == it->disallow_perms.end(),
53 "authorized_by appears in disallow_perms");