Mercurial > irccd
changeset 229:74d8aa0fd7f5
Irccd: fix server-join command with password
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 18 Jul 2016 22:39:14 +0200 |
parents | e754e79ca152 |
children | 4f64b53ecd98 |
files | lib/irccd/cmd-server-join.cpp |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/irccd/cmd-server-join.cpp Mon Jul 18 22:28:18 2016 +0200 +++ b/lib/irccd/cmd-server-join.cpp Mon Jul 18 22:39:14 2016 +0200 @@ -48,8 +48,7 @@ { return { { "server", { nlohmann::json::value_t::string }}, - { "channel", { nlohmann::json::value_t::string }}, - { "password", { nlohmann::json::value_t::string }} + { "channel", { nlohmann::json::value_t::string }} }; } @@ -61,7 +60,7 @@ }); if (args.length() == 3) - req.push_back(nlohmann::json::object({"password", args.args()[2]})); + req.push_back({"password", args.args()[2]}); return req; } @@ -70,12 +69,15 @@ { Command::exec(irccd, request); - auto password = request["password"]; + std::string password; + + if (request.find("password") != request.end()) + password = request["password"]; irccd.serverService().require( request.at("server").get<std::string>())->join( request.at("channel").get<std::string>(), - password.is_string() ? password.get<std::string>() : "" + password ); return nlohmann::json::object();