Software /
code /
prosody
Comparison
plugins/mod_invites.lua @ 13012:c2616274bef7
mod_invites: Record roles as ordered list, first becoming primary role
For mod_invites_register to apply on user creation.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 30 Mar 2023 11:09:08 +0200 |
parent | 12977:74b9e05af71e |
child | 13096:9638ff8b1c81 |
comparison
equal
deleted
inserted
replaced
13011:16b47c3b44f3 | 13012:c2616274bef7 |
---|---|
255 if mm.get_modules_for_host(host):contains(invites_page_module) then | 255 if mm.get_modules_for_host(host):contains(invites_page_module) then |
256 module:depends(invites_page_module); | 256 module:depends(invites_page_module); |
257 end | 257 end |
258 | 258 |
259 local allow_reset; | 259 local allow_reset; |
260 local roles; | 260 local roles = {}; |
261 local groups = {}; | 261 local groups = {}; |
262 | 262 |
263 while #arg > 0 do | 263 while #arg > 0 do |
264 local value = arg[1]; | 264 local value = arg[1]; |
265 table.remove(arg, 1); | 265 table.remove(arg, 1); |
280 print(" Equivalent to --role prosody:admin") | 280 print(" Equivalent to --role prosody:admin") |
281 print(" --role ROLE Grant the given ROLE to the new user") | 281 print(" --role ROLE Grant the given ROLE to the new user") |
282 print(" --group GROUPID Add the user to the group with the given ID") | 282 print(" --group GROUPID Add the user to the group with the given ID") |
283 print(" Can be specified multiple times") | 283 print(" Can be specified multiple times") |
284 print() | 284 print() |
285 print("--role and --admin override each other; the last one wins") | 285 print("--role and --admin can be specified multiple times; the first role becomes the primary role, the rest become secondary roles") |
286 print("--group can be specified multiple times; the user will be added to all groups.") | 286 print("--group can be specified multiple times; the user will be added to all groups.") |
287 print() | 287 print() |
288 print("--reset and the other options cannot be mixed.") | 288 print("--reset and the other options cannot be mixed.") |
289 return 2 | 289 return 2 |
290 elseif value == "--reset" then | 290 elseif value == "--reset" then |
295 print("Please supply a valid username to generate a reset link for"); | 295 print("Please supply a valid username to generate a reset link for"); |
296 return 2; | 296 return 2; |
297 end | 297 end |
298 allow_reset = username; | 298 allow_reset = username; |
299 elseif value == "--admin" then | 299 elseif value == "--admin" then |
300 roles = { ["prosody:admin"] = true }; | 300 table.insert(roles, "prosody:admin"); |
301 elseif value == "--role" then | 301 elseif value == "--role" then |
302 local rolename = arg[1]; | 302 local rolename = arg[1]; |
303 if not rolename then | 303 if not rolename then |
304 print("Please supply a role name"); | 304 print("Please supply a role name"); |
305 return 2; | 305 return 2; |
306 end | 306 end |
307 roles = { [rolename] = true }; | 307 table.insert(roles, rolename); |
308 table.remove(arg, 1); | 308 table.remove(arg, 1); |
309 elseif value == "--group" or value == "-g" then | 309 elseif value == "--group" or value == "-g" then |
310 local groupid = arg[1]; | 310 local groupid = arg[1]; |
311 if not groupid then | 311 if not groupid then |
312 print("Please supply a group ID") | 312 print("Please supply a group ID") |