Software /
code /
prosody
Comparison
prosodyctl @ 13600:854df134274f
prosodyctl: deluser: Use user:delete() shell command for implementation
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 07 Jan 2025 19:28:06 +0000 |
parent | 13599:54803fb5b4d4 |
child | 13606:6127b51803bb |
comparison
equal
deleted
inserted
replaced
13599:54803fb5b4d4 | 13600:854df134274f |
---|---|
166 local opts = parse_args(arg, only_help); | 166 local opts = parse_args(arg, only_help); |
167 if opts.help or not arg[1] then | 167 if opts.help or not arg[1] then |
168 show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); | 168 show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); |
169 return opts.help and 0 or 1; | 169 return opts.help and 0 or 1; |
170 end | 170 end |
171 local user, host = jid_split(arg[1]); | 171 |
172 if not user and host then | 172 local shell = require "prosody.util.prosodyctl.shell"; |
173 show_message [[Failed to understand JID, please supply the JID to the user account you want to delete]] | 173 return shell.shell({ ("user:delete(%q)"):format(arg[1]) }); |
174 show_usage [[deluser user@host]] | |
175 return 1; | |
176 end | |
177 | |
178 if not host then | |
179 show_message [[Please specify a JID, including a host. e.g. alice@example.com]]; | |
180 return 1; | |
181 end | |
182 | |
183 if not prosody.hosts[host] then | |
184 show_warning("The host '%s' is not listed in the configuration file (or is not enabled).", host) | |
185 prosody.hosts[host] = startup.make_host(host); --luacheck: ignore 122 | |
186 end | |
187 | |
188 if not prosodyctl.user_exists { user = user, host = host } then | |
189 show_message [[That user does not exist on this server]] | |
190 return 1; | |
191 end | |
192 | |
193 local ok, msg = prosodyctl.deluser { user = user, host = host }; | |
194 | |
195 if ok then return 0; end | |
196 | |
197 show_message(error_messages[msg]) | |
198 return 1; | |
199 end | 174 end |
200 | 175 |
201 local function has_init_system() --> which | 176 local function has_init_system() --> which |
202 lfs = lfs or require"lfs"; | 177 lfs = lfs or require"lfs"; |
203 if lfs.attributes("/etc/systemd") then | 178 if lfs.attributes("/etc/systemd") then |