mirror of
https://github.com/matrix-construct/construct
synced 2024-11-19 08:21:09 +01:00
modules/client/devices: Revoke access tokens when devices deleted.
This commit is contained in:
parent
694b208829
commit
a1d4e448ea
2 changed files with 26 additions and 2 deletions
|
@ -74,12 +74,26 @@ post__delete_devices(client &client,
|
|||
request.user_id
|
||||
};
|
||||
|
||||
const m::user::tokens access_tokens
|
||||
{
|
||||
request.user_id
|
||||
};
|
||||
|
||||
size_t revoked(0);
|
||||
for(const json::string device_id : devices)
|
||||
user_devices.del(device_id);
|
||||
revoked += access_tokens.del_by_device(device_id, "device deleted");
|
||||
|
||||
size_t deleted(0);
|
||||
for(const json::string device_id : devices)
|
||||
deleted += user_devices.del(device_id);
|
||||
|
||||
return m::resource::response
|
||||
{
|
||||
client, http::OK
|
||||
client, json::members
|
||||
{
|
||||
{ "deleted", long(deleted) },
|
||||
{ "revoked", long(revoked) },
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,16 @@ delete__devices(client &client,
|
|||
"Incorrect password."
|
||||
};
|
||||
|
||||
const m::user::tokens tokens
|
||||
{
|
||||
request.user_id
|
||||
};
|
||||
|
||||
const size_t revoked
|
||||
{
|
||||
tokens.del_by_device(device_id)
|
||||
};
|
||||
|
||||
const m::user::devices devices
|
||||
{
|
||||
request.user_id
|
||||
|
|
Loading…
Reference in a new issue