0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

modules: Replace hardcoded hosts with my_host().

This commit is contained in:
Jason Volk 2017-10-01 03:09:28 -07:00
parent ec89d0ca25
commit 189de14f1e
2 changed files with 11 additions and 23 deletions

View file

@ -28,12 +28,6 @@ resource login_resource
"they can use to authorize themself in subsequent requests. (3.2.2)"
};
const auto home_server
{
// "The hostname of the homeserver on which the account has been registered."
"cdc.z"
};
namespace { namespace name
{
constexpr const auto password{"password"};
@ -63,10 +57,10 @@ post_login_password(client &client,
// Build a canonical MXID from a the user field
const m::id::user::buf user_id
{
unquote(at<name::user>(request)), home_server
unquote(at<name::user>(request)), my_host()
};
if(!user_id.valid() || user_id.host() != home_server)
if(!user_id.valid() || user_id.host() != my_host())
throw m::error
{
http::FORBIDDEN, "M_FORBIDDEN", "Access denied."
@ -113,7 +107,7 @@ post_login_password(client &client,
{ "state_key", access_token },
{ "content", json::members
{
{ "ip", string(remote_addr(client)) },
{ "ip", string(remote(client)) },
{ "device", "unknown" },
}}
});
@ -124,7 +118,7 @@ post_login_password(client &client,
client,
{
{ "user_id", user_id },
{ "home_server", home_server },
{ "home_server", my_host() },
{ "access_token", access_token },
}
};

View file

@ -21,12 +21,6 @@
using namespace ircd;
const auto home_server
{
// "The hostname of the homeserver on which the account has been registered."
"cdc.z"
};
namespace { namespace name
{
constexpr const auto username {"username"};
@ -85,7 +79,7 @@ handle_post_kind_user(client &client,
// specified. TODO: isn't that guest reg?
const m::id::user::buf user_id
{
username, home_server
username, my_host()
};
// Check if the the user_id is acceptably formed for this server or throws
@ -132,7 +126,7 @@ handle_post_kind_user(client &client,
client, http::CREATED,
{
{ "user_id", user_id },
{ "home_server", home_server },
{ "home_server", my_host() },
// { "access_token", access_token },
}
};
@ -144,7 +138,7 @@ handle_post_kind_guest(client &client,
{
const m::id::user::buf user_id
{
m::generate, home_server
m::generate, my_host()
};
return resource::response
@ -152,7 +146,7 @@ handle_post_kind_guest(client &client,
client, http::CREATED,
{
{ "user_id", user_id },
{ "home_server", home_server },
{ "home_server", my_host() },
// { "access_token", access_token },
}
};
@ -204,10 +198,10 @@ validate_user_id(const m::id::user &user_id)
"M_INVALID_USERNAME", "The desired user ID is not a valid user name."
};
if(user_id.host() != home_server)
if(user_id.host() != my_host())
throw m::error
{
"M_INVALID_USERNAME", "Can only register with host '%s'", home_server
"M_INVALID_USERNAME", "Can only register with host '%s'", my_host()
};
}