317 -- ejabberdctl compatibility |
317 -- ejabberdctl compatibility |
318 |
318 |
319 function commands.register(arg) |
319 function commands.register(arg) |
320 local user, host, password = unpack(arg); |
320 local user, host, password = unpack(arg); |
321 if (not (user and host)) or arg[1] == "--help" then |
321 if (not (user and host)) or arg[1] == "--help" then |
322 if not user and user ~= "--help" then |
322 if user ~= "--help" then |
323 show_message [[No username specified]] |
323 if not user then |
324 elseif not host then |
324 show_message [[No username specified]] |
325 show_message [[Please specify which host you want to register the user on]]; |
325 elseif not host then |
|
326 show_message [[Please specify which host you want to register the user on]]; |
|
327 end |
326 end |
328 end |
327 show_usage("register USER HOST [PASSWORD]", "Register a user on the server, with the given password"); |
329 show_usage("register USER HOST [PASSWORD]", "Register a user on the server, with the given password"); |
328 return 1; |
330 return 1; |
329 end |
331 end |
330 if not password then |
332 if not password then |
344 end |
346 end |
345 |
347 |
346 function commands.unregister(arg) |
348 function commands.unregister(arg) |
347 local user, host = unpack(arg); |
349 local user, host = unpack(arg); |
348 if (not (user and host)) or arg[1] == "--help" then |
350 if (not (user and host)) or arg[1] == "--help" then |
349 if not user then |
351 if user ~= "--help" then |
350 show_message [[No username specified]] |
352 if not user then |
351 elseif not host then |
353 show_message [[No username specified]] |
352 show_message [[Please specify which host you want to unregister the user from]]; |
354 elseif not host then |
353 end |
355 show_message [[Please specify which host you want to unregister the user from]]; |
354 show_usage("register USER HOST [PASSWORD]", "Permanently remove a user account from the server"); |
356 end |
|
357 end |
|
358 show_usage("unregister USER HOST [PASSWORD]", "Permanently remove a user account from the server"); |
355 return 1; |
359 return 1; |
356 end |
360 end |
357 |
361 |
358 local ok, msg = prosodyctl.deluser { user = user, host = host }; |
362 local ok, msg = prosodyctl.deluser { user = user, host = host }; |
359 |
363 |
376 print(""); |
380 print(""); |
377 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
381 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); |
378 print(""); |
382 print(""); |
379 print("Where COMMAND may be one of:\n"); |
383 print("Where COMMAND may be one of:\n"); |
380 |
384 |
|
385 local hidden_commands = require "util.set".new{ "register", "unregister" }; |
381 local commands_order = { "adduser", "passwd", "deluser" }; |
386 local commands_order = { "adduser", "passwd", "deluser" }; |
382 |
387 |
383 local done = {}; |
388 local done = {}; |
384 |
389 |
385 for _, command_name in ipairs(commands_order) do |
390 for _, command_name in ipairs(commands_order) do |