ircd:Ⓜ️:user::tokens: Add method to delete access tokens by device_id.
This commit is contained in:
parent
eb0a564d0b
commit
694b208829
|
@ -27,6 +27,7 @@ struct ircd::m::user::tokens
|
||||||
bool for_each(const closure_bool &) const;
|
bool for_each(const closure_bool &) const;
|
||||||
bool check(const string_view &token) const;
|
bool check(const string_view &token) const;
|
||||||
bool del(const string_view &token, const string_view &reason) const;
|
bool del(const string_view &token, const string_view &reason) const;
|
||||||
|
size_t del_by_device(const string_view &device_id, const string_view &reason = {}) const;
|
||||||
size_t del(const string_view &reason) const;
|
size_t del(const string_view &reason) const;
|
||||||
m::event::id::buf add(const string_view &, const json::object & = {}) const;
|
m::event::id::buf add(const string_view &, const json::object & = {}) const;
|
||||||
string_view create(const mutable_buffer &, const json::object & = {}) const;
|
string_view create(const mutable_buffer &, const json::object & = {}) const;
|
||||||
|
|
|
@ -59,6 +59,32 @@ const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
ircd::m::user::tokens::del_by_device(const string_view &device_id,
|
||||||
|
const string_view &reason)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
size_t ret(0);
|
||||||
|
for_each([this, &ret, &device_id, &reason]
|
||||||
|
(const event::idx &event_idx, const string_view &token)
|
||||||
|
{
|
||||||
|
const auto match
|
||||||
|
{
|
||||||
|
[&device_id](const json::object &content)
|
||||||
|
{
|
||||||
|
return json::string{content["device_id"]} == device_id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(m::query(std::nothrow, event_idx, "content", false, match))
|
||||||
|
ret += del(token, reason);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::m::user::tokens::del(const string_view &token,
|
ircd::m::user::tokens::del(const string_view &token,
|
||||||
const string_view &reason)
|
const string_view &reason)
|
||||||
|
|
Loading…
Reference in New Issue