Software /
code /
prosody
Comparison
plugins/mod_authz_internal.lua @ 13679:f5c7fe7bbe3b 13.0
mod_authz_internal: Fix error messages
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 13 Feb 2025 15:31:14 +0000 |
parent | 13678:acb87cc2d48b |
comparison
equal
deleted
inserted
replaced
13678:acb87cc2d48b | 13679:f5c7fe7bbe3b |
---|---|
159 | 159 |
160 -- Set the primary role of a user | 160 -- Set the primary role of a user |
161 function set_user_role(user, role_name) | 161 function set_user_role(user, role_name) |
162 local role = role_registry[role_name]; | 162 local role = role_registry[role_name]; |
163 if not role then | 163 if not role then |
164 return error("Cannot assign default user an unknown role: "..tostring(role_name)); | 164 return error("Cannot assign user an unknown role: "..tostring(role_name)); |
165 end | 165 end |
166 local keys_update = { | 166 local keys_update = { |
167 _default = role_name; | 167 _default = role_name; |
168 -- Primary role cannot be secondary role | 168 -- Primary role cannot be secondary role |
169 [role_name] = role_map_store.remove; | 169 [role_name] = role_map_store.remove; |
180 end | 180 end |
181 | 181 |
182 function add_user_secondary_role(user, role_name) | 182 function add_user_secondary_role(user, role_name) |
183 local role = role_registry[role_name]; | 183 local role = role_registry[role_name]; |
184 if not role then | 184 if not role then |
185 return error("Cannot assign default user an unknown role: "..tostring(role_name)); | 185 return error("Cannot assign user an unknown role: "..tostring(role_name)); |
186 end | 186 end |
187 local ok, err = role_map_store:set(user, role_name, true); | 187 local ok, err = role_map_store:set(user, role_name, true); |
188 if not ok then | 188 if not ok then |
189 return nil, err; | 189 return nil, err; |
190 end | 190 end |