From 7d449e6e56ca25e868327c352e19cd3db12134c7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 18 Feb 2019 12:38:01 -0800 Subject: [PATCH] ircd::m::login: Use json::string rather than string_view in tuple types; simplify. --- include/ircd/m/login.h | 16 ++++++++-------- modules/client/login.cc | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/ircd/m/login.h b/include/ircd/m/login.h index bb1a2e73c..28467d973 100644 --- a/include/ircd/m/login.h +++ b/include/ircd/m/login.h @@ -21,33 +21,33 @@ struct ircd::m::login < /// Required. The login type being used. One of: ["m.login.password", /// "m.login.token"] - json::property, + json::property, /// The fully qualified user ID or just local part of the user ID, to /// log in. - json::property, + json::property, /// When logging in using a third party identifier, the medium of the /// identifier. Must be 'email'. - json::property, + json::property, /// Third party identifier for the user. - json::property, + json::property, /// Required when type is m.login.password. The user's password. - json::property, + json::property, /// Required when type is m.login.token. The login token. - json::property, + json::property, /// ID of the client device. If this does not correspond to a known client /// device, a new device will be created. The server will auto-generate a /// device_id if this is not specified. - json::property, + json::property, /// A display name to assign to the newly-created device. Ignored if /// device_id corresponds to a known device. - json::property + json::property > { using super_type::tuple; diff --git a/modules/client/login.cc b/modules/client/login.cc index 0b3e616c1..f5282a0ad 100644 --- a/modules/client/login.cc +++ b/modules/client/login.cc @@ -33,12 +33,12 @@ post__login_password(client &client, // Build a canonical MXID from a the user field const m::id::user::buf user_id { - unquote(at<"user"_>(request)), my_host() + at<"user"_>(request), my_host() }; - const auto &supplied_password + const string_view &supplied_password { - unquote(at<"password"_>(request)) + at<"password"_>(request) }; m::user user @@ -58,9 +58,14 @@ post__login_password(client &client, "Access denied." }; - const auto requested_device_id + const string_view &requested_device_id { - unquote(json::get<"device_id"_>(request)) + json::get<"device_id"_>(request) + }; + + const string_view &initial_device_display_name + { + json::get<"initial_device_display_name"_>(request) }; const auto device_id @@ -104,7 +109,7 @@ post__login(client &client, { const auto &type { - unquote(at<"type"_>(request)) + at<"type"_>(request) }; if(type == "m.login.password") @@ -112,7 +117,7 @@ post__login(client &client, throw m::UNSUPPORTED { - "Login type is not supported." + "Login type '%s' is not supported.", type }; }