mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd: Refer to the right access_token in the resource::request struct.
This commit is contained in:
parent
b1d257c93a
commit
0afaa70ccf
2 changed files with 8 additions and 5 deletions
|
@ -87,6 +87,7 @@ struct ircd::resource::request
|
|||
string_view content;
|
||||
http::query::string query;
|
||||
string_view user_id; //m::user::id::buf user_id; //TODO: bleeding
|
||||
string_view access_token;
|
||||
vector_view<string_view> parv;
|
||||
|
||||
request(const http::request::head &head,
|
||||
|
@ -104,6 +105,7 @@ struct ircd::resource::request::object
|
|||
const string_view &content;
|
||||
const http::query::string &query;
|
||||
const decltype(r.user_id) &user_id;
|
||||
const decltype(r.access_token) &access_token;
|
||||
const vector_view<string_view> &parv;
|
||||
const json::object &body;
|
||||
|
||||
|
@ -114,6 +116,7 @@ struct ircd::resource::request::object
|
|||
,content{r.content}
|
||||
,query{r.query}
|
||||
,user_id{r.user_id}
|
||||
,access_token{r.access_token}
|
||||
,parv{r.parv}
|
||||
,body{r}
|
||||
{}
|
||||
|
|
|
@ -129,12 +129,12 @@ ircd::authenticate(client &client,
|
|||
resource::request &request)
|
||||
try
|
||||
{
|
||||
string_view access_token
|
||||
request.access_token =
|
||||
{
|
||||
request.query["access_token"]
|
||||
};
|
||||
|
||||
if(empty(access_token))
|
||||
if(empty(request.access_token))
|
||||
{
|
||||
const auto authorization
|
||||
{
|
||||
|
@ -142,13 +142,13 @@ try
|
|||
};
|
||||
|
||||
if(iequals(authorization.first, "bearer"_sv))
|
||||
access_token = authorization.second;
|
||||
request.access_token = authorization.second;
|
||||
}
|
||||
|
||||
const bool result
|
||||
{
|
||||
access_token &&
|
||||
m::user::sessions.get(std::nothrow, "ircd.access_token"_sv, access_token, [&]
|
||||
request.access_token &&
|
||||
m::user::sessions.get(std::nothrow, "ircd.access_token"_sv, request.access_token, [&]
|
||||
(const m::event &event)
|
||||
{
|
||||
// The user sent this access token to the sessions room.
|
||||
|
|
Loading…
Reference in a new issue