Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 12908:e96c3ea64996
mod_admin_shell: Add commands to disable and enable accounts
First proper UI to enable/disable, allowing it to be tested.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 23 Feb 2023 18:10:06 +0100 |
parent | 12888:b8504b71735d |
child | 12922:aaf055d6fe7a |
comparison
equal
deleted
inserted
replaced
12907:d2333b468d07 | 12908:e96c3ea64996 |
---|---|
273 print [[user:password(jid, password) - Set the password for the specified user account]] | 273 print [[user:password(jid, password) - Set the password for the specified user account]] |
274 print [[user:roles(jid, host) - Show current roles for an user]] | 274 print [[user:roles(jid, host) - Show current roles for an user]] |
275 print [[user:setrole(jid, host, role) - Set primary role of a user (see 'help roles')]] | 275 print [[user:setrole(jid, host, role) - Set primary role of a user (see 'help roles')]] |
276 print [[user:addrole(jid, host, role) - Add a secondary role to a user]] | 276 print [[user:addrole(jid, host, role) - Add a secondary role to a user]] |
277 print [[user:delrole(jid, host, role) - Remove a secondary role from a user]] | 277 print [[user:delrole(jid, host, role) - Remove a secondary role from a user]] |
278 print [[user:disable(jid) - Disable the specified user account, preventing login]] | |
279 print [[user:enable(jid) - Enable the specified user account, restoring login access]] | |
278 print [[user:delete(jid) - Permanently remove the specified user account]] | 280 print [[user:delete(jid) - Permanently remove the specified user account]] |
279 print [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]] | 281 print [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]] |
280 elseif section == "roles" then | 282 elseif section == "roles" then |
281 print [[Roles may grant access or restrict users from certain operations]] | 283 print [[Roles may grant access or restrict users from certain operations]] |
282 print [[Built-in roles are:]] | 284 print [[Built-in roles are:]] |
1519 end | 1521 end |
1520 | 1522 |
1521 return true, "User created"; | 1523 return true, "User created"; |
1522 end | 1524 end |
1523 | 1525 |
1526 function def_env.user:disable(jid) | |
1527 local username, host = jid_split(jid); | |
1528 if not prosody.hosts[host] then | |
1529 return nil, "No such host: "..host; | |
1530 elseif not um.user_exists(username, host) then | |
1531 return nil, "No such user"; | |
1532 end | |
1533 local ok, err = um.disable_user(username, host); | |
1534 if ok then | |
1535 return true, "User disabled"; | |
1536 else | |
1537 return nil, "Could not disable user: "..err; | |
1538 end | |
1539 end | |
1540 | |
1541 function def_env.user:enable(jid) | |
1542 local username, host = jid_split(jid); | |
1543 if not prosody.hosts[host] then | |
1544 return nil, "No such host: "..host; | |
1545 elseif not um.user_exists(username, host) then | |
1546 return nil, "No such user"; | |
1547 end | |
1548 local ok, err = um.enable_user(username, host); | |
1549 if ok then | |
1550 return true, "User enabled"; | |
1551 else | |
1552 return nil, "Could not enable user: "..err; | |
1553 end | |
1554 end | |
1555 | |
1524 function def_env.user:delete(jid) | 1556 function def_env.user:delete(jid) |
1525 local username, host = jid_split(jid); | 1557 local username, host = jid_split(jid); |
1526 if not prosody.hosts[host] then | 1558 if not prosody.hosts[host] then |
1527 return nil, "No such host: "..host; | 1559 return nil, "No such host: "..host; |
1528 elseif not um.user_exists(username, host) then | 1560 elseif not um.user_exists(username, host) then |