0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-03-13 21:10:32 +01:00

modules/client/login: Support both full mxid and localpart to login.

This commit is contained in:
Jason Volk 2020-04-14 18:22:17 -07:00
parent 6bbe8b8855
commit 75a8b2b621

View file

@ -53,10 +53,31 @@ post__login_password(client &client,
at<"user"_>(request)
};
const auto &localpart
{
valid(m::id::USER, username)?
m::id::user(username).local():
string_view{username}
};
const auto &hostpart
{
valid(m::id::USER, username)?
m::id::user(username).host():
my_host()
};
if(!my_host(hostpart))
throw m::UNSUPPORTED
{
"Credentials for users of homeserver '%s' cannot be obtained here.",
hostpart,
};
// Build a canonical MXID from a the user field
const m::id::user::buf user_id
{
username, my_host()
localpart, hostpart
};
const string_view &supplied_password