0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd:Ⓜ️:device: Typedef device::id; add func to get device from access_token.

This commit is contained in:
Jason Volk 2019-02-20 18:58:49 -08:00
parent 1dd97b8c75
commit a3923e8374
3 changed files with 20 additions and 0 deletions

View file

@ -127,6 +127,7 @@ struct ircd::m::device
json::property<name::access_token_id, json::string>
>
{
using id = m::id::device;
using closure = std::function<void (const string_view &)>;
using closure_bool = std::function<bool (const string_view &)>;

View file

@ -39,6 +39,7 @@ struct ircd::m::user
operator const id &() const;
static string_view gen_access_token(const mutable_buffer &out);
static id::device::buf get_device_from_access_token(const string_view &token);
id::room room_id(const mutable_buffer &) const;
id::room::buf room_id() const;

View file

@ -2388,6 +2388,24 @@ const
};
}
ircd::m::device::id::buf
ircd::m::user::get_device_from_access_token(const string_view &token)
{
const event::idx event_idx
{
user::tokens.get("ircd.access_token", token)
};
device::id::buf ret;
m::get(event_idx, "content", [&ret]
(const json::object &content)
{
ret = unquote(content.at("device_id"));
});
return ret;
}
ircd::string_view
ircd::m::user::gen_access_token(const mutable_buffer &buf)
{