mod_admin_shell: user:create(): request password via prompt if none given

This commit is contained in:
Matthew Wild 2025-01-07 18:17:57 +00:00
parent 7a9bc06049
commit 54718fffe0

View file

@ -1724,12 +1724,13 @@ function def_env.user:create(jid, password, role)
role = module:get_option_string("default_provisioned_role", "prosody:member");
end
local ok, err = um.create_user_with_role(username, password, host, role);
if not ok then
return nil, "Could not create user: "..err;
end
return true, ("Created %s with role '%s'"):format(jid, role);
return promise.resolve(password or self.session.request_input("password")):next(function (password_)
local ok, err = um.create_user_with_role(username, password_, host, role);
if not ok then
return nil, "Could not create user: "..err;
end
return ("Created %s with role '%s'"):format(jid, role);
end);
end
describe_command [[user:disable(jid) - Disable the specified user account, preventing login]]