Software /
code /
prosody
Comparison
prosodyctl @ 5610:f73d5fb4ea13
prosodyctl: Use jid.split() to parse parameter to adduser/deluser/passwd
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 20 May 2013 15:33:57 +0100 |
parent | 5592:5705e21ba24b |
child | 5616:a79c6717ee2b |
comparison
equal
deleted
inserted
replaced
5609:f12d1c03dd94 | 5610:f73d5fb4ea13 |
---|---|
272 ----------------------- | 272 ----------------------- |
273 local commands = {}; | 273 local commands = {}; |
274 local command = arg[1]; | 274 local command = arg[1]; |
275 | 275 |
276 function commands.adduser(arg) | 276 function commands.adduser(arg) |
277 local jid_split = require "util.jid".split; | |
277 if not arg[1] or arg[1] == "--help" then | 278 if not arg[1] or arg[1] == "--help" then |
278 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); | 279 show_usage([[adduser JID]], [[Create the specified user account in Prosody]]); |
279 return 1; | 280 return 1; |
280 end | 281 end |
281 local user, host = arg[1]:match("([^@]+)@(.+)"); | 282 local user, host = jid_split(arg[1]); |
282 if not user and host then | 283 if not user and host then |
283 show_message [[Failed to understand JID, please supply the JID you want to create]] | 284 show_message [[Failed to understand JID, please supply the JID you want to create]] |
284 show_usage [[adduser user@host]] | 285 show_usage [[adduser user@host]] |
285 return 1; | 286 return 1; |
286 end | 287 end |
311 show_message(msg) | 312 show_message(msg) |
312 return 1; | 313 return 1; |
313 end | 314 end |
314 | 315 |
315 function commands.passwd(arg) | 316 function commands.passwd(arg) |
317 local jid_split = require "util.jid".split; | |
316 if not arg[1] or arg[1] == "--help" then | 318 if not arg[1] or arg[1] == "--help" then |
317 show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]); | 319 show_usage([[passwd JID]], [[Set the password for the specified user account in Prosody]]); |
318 return 1; | 320 return 1; |
319 end | 321 end |
320 local user, host = arg[1]:match("([^@]+)@(.+)"); | 322 local user, host = jid_split(arg[1]); |
321 if not user and host then | 323 if not user and host then |
322 show_message [[Failed to understand JID, please supply the JID you want to set the password for]] | 324 show_message [[Failed to understand JID, please supply the JID you want to set the password for]] |
323 show_usage [[passwd user@host]] | 325 show_usage [[passwd user@host]] |
324 return 1; | 326 return 1; |
325 end | 327 end |
350 show_message(error_messages[msg]) | 352 show_message(error_messages[msg]) |
351 return 1; | 353 return 1; |
352 end | 354 end |
353 | 355 |
354 function commands.deluser(arg) | 356 function commands.deluser(arg) |
357 local jid_split = require "util.jid".split; | |
355 if not arg[1] or arg[1] == "--help" then | 358 if not arg[1] or arg[1] == "--help" then |
356 show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); | 359 show_usage([[deluser JID]], [[Permanently remove the specified user account from Prosody]]); |
357 return 1; | 360 return 1; |
358 end | 361 end |
359 local user, host = arg[1]:match("([^@]+)@(.+)"); | 362 local user, host = jid_split(arg[1]); |
360 if not user and host then | 363 if not user and host then |
361 show_message [[Failed to understand JID, please supply the JID you want to set the password for]] | 364 show_message [[Failed to understand JID, please supply the JID you want to set the password for]] |
362 show_usage [[passwd user@host]] | 365 show_usage [[passwd user@host]] |
363 return 1; | 366 return 1; |
364 end | 367 end |