More scoping by user ID at DB level.
This commit is contained in:
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT id, app_id, secret_hash, expires_at, created_at\n FROM user_app_secrets\n WHERE app_id = $1\n ORDER BY created_at DESC, id DESC\n LIMIT $2\n OFFSET $3\n ",
|
||||
"query": "\n SELECT id, app_id, secret_hash, expires_at, created_at\n FROM user_app_secrets\n WHERE app_id IN (SELECT id FROM user_apps WHERE user_id = $1)\n AND app_id = $2\n ORDER BY created_at DESC, id DESC\n LIMIT $3\n OFFSET $4\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -61,6 +61,7 @@
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Int8",
|
||||
"Int8"
|
||||
@@ -74,5 +75,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "8d016626a5df98a049b4d32abe1fc8f4625ecc6abde27ae037a6e461e0fe0b6e"
|
||||
"hash": "1ad543cbedd620af3577784a64af86ce591b4e1cc695b286baff424d8032e3fb"
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT user_id FROM user_apps WHERE id = $1 FOR KEY SHARE",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "user_id",
|
||||
"type_info": "Uuid",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "user_apps",
|
||||
"name": "user_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "53d120ed51ed58125e16bafaaf2850c48fbc5c5a259b0e0a6558d02828b98d98"
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO user_app_secrets (id, app_id, secret_hash, expires_at)\n VALUES ($1, $2, $3, $4)\n ON CONFLICT (id, app_id) DO UPDATE SET\n secret_hash = EXCLUDED.secret_hash,\n expires_at = EXCLUDED.expires_at\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n COALESCE(old_row.app_id, new_row.app_id) AS \"old_app_id!\",\n COALESCE(old_row.secret_hash, new_row.secret_hash) AS \"old_secret_hash!\",\n COALESCE(old_row.expires_at, new_row.expires_at) AS \"old_expires_at!\",\n COALESCE(old_row.created_at, new_row.created_at) AS \"old_created_at!\",\n new_row.id AS \"id!\",\n new_row.app_id AS \"app_id!\",\n new_row.secret_hash AS \"secret_hash!\",\n new_row.expires_at AS \"expires_at!\",\n new_row.created_at AS \"created_at!\"\n ",
|
||||
"query": "\n INSERT INTO user_app_secrets (id, app_id, secret_hash, expires_at)\n SELECT $2, $3, $4, $5\n FROM user_apps\n WHERE user_id = $1 AND id = $3\n FOR KEY SHARE\n ON CONFLICT (id, app_id) DO UPDATE SET\n secret_hash = EXCLUDED.secret_hash,\n expires_at = EXCLUDED.expires_at\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n COALESCE(old_row.app_id, new_row.app_id) AS \"old_app_id!\",\n COALESCE(old_row.secret_hash, new_row.secret_hash) AS \"old_secret_hash!\",\n COALESCE(old_row.expires_at, new_row.expires_at) AS \"old_expires_at!\",\n COALESCE(old_row.created_at, new_row.created_at) AS \"old_created_at!\",\n new_row.id AS \"id!\",\n new_row.app_id AS \"app_id!\",\n new_row.secret_hash AS \"secret_hash!\",\n new_row.expires_at AS \"expires_at!\",\n new_row.created_at AS \"created_at!\"\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -96,6 +96,7 @@
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Bytea",
|
||||
@@ -115,5 +116,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "18f30fc05dd48c2c65659cf16f167207303707d544f8bede6407790d97c8b927"
|
||||
"hash": "6e94a9a8c3d5f266a8e53b99c6d9af63b87d279c09b1c484315eea1cd3e08459"
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n DELETE FROM user_app_secrets\n WHERE app_id = $1 AND id = $2\n RETURNING id, app_id, secret_hash, expires_at, created_at\n ",
|
||||
"query": "\n DELETE FROM user_app_secrets\n WHERE app_id IN (SELECT id FROM user_apps WHERE user_id = $1)\n AND app_id = $2\n AND id = $3\n RETURNING id, app_id, secret_hash, expires_at, created_at\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -61,6 +61,7 @@
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Uuid"
|
||||
]
|
||||
@@ -73,5 +74,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "209942ca0122a766d9170ceb6e53171788ff889717615205cbc6f8bde9a2fe63"
|
||||
"hash": "9f08c5205c1efd98080544b60a13c9452ff9082d851bc29de182a5871ebcbabd"
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT id, app_id, secret_hash, expires_at, created_at\n FROM user_app_secrets\n WHERE app_id = $1 AND id = $2\n ",
|
||||
"query": "\n SELECT id, app_id, secret_hash, expires_at, created_at\n FROM user_app_secrets\n WHERE app_id IN (SELECT id FROM user_apps WHERE user_id = $1)\n AND app_id = $2\n AND id = $3\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -61,6 +61,7 @@
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid",
|
||||
"Uuid"
|
||||
]
|
||||
@@ -73,5 +74,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "b7d48fe3fd0300c94344d7d8e93ceead2cf1ff00bd837c0fc42ec81347faa383"
|
||||
"hash": "cec05471697838fb2aaaa36cb1876daa07c34c8f59d06da1d92a8adea3a8f03b"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO user_apps (id, user_id)\n VALUES ($1, $2)\n ON CONFLICT (id) DO UPDATE SET\n user_id = user_apps.user_id\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n COALESCE(old_row.user_id, new_row.user_id) AS \"old_user_id!\",\n new_row.id AS \"id!\",\n new_row.user_id AS \"user_id!\"\n ",
|
||||
"query": "\n INSERT INTO user_apps (id, user_id)\n VALUES ($1, $2)\n ON CONFLICT (id) DO UPDATE SET\n user_id = user_apps.user_id\n WHERE user_apps.user_id = EXCLUDED.user_id\n RETURNING WITH (OLD AS old_row, NEW AS new_row)\n old_row.id AS \"old_id?\",\n COALESCE(old_row.user_id, new_row.user_id) AS \"old_user_id!\",\n new_row.id AS \"id!\",\n new_row.user_id AS \"user_id!\"\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -56,5 +56,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "bf2a5b137b07bc056060d1e2d55f096ec1f7279f90d37c3c11f6b4dc71708db9"
|
||||
"hash": "ed91880a0398df14f4886a622c5432712c70187d08dea243809986a45fec4f68"
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM user_apps WHERE user_id = $1 AND id = $2 RETURNING id, user_id",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "user_apps",
|
||||
"name": "id"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "user_id",
|
||||
"type_info": "Uuid",
|
||||
"origin": {
|
||||
"Table": {
|
||||
"table": "user_apps",
|
||||
"name": "user_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "ef7cd037118a0ce24b225d60fa156d552323461169feb86fd6a532524897f144"
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "DELETE FROM user_apps WHERE id = $1 RETURNING id, user_id",
|
||||
"query": "SELECT id, user_id FROM user_apps WHERE user_id = $1 AND id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -28,6 +28,7 @@
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
@@ -36,5 +37,5 @@
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "40214db76bbef12fdb3acb184b115d7ddc4e266cbbc7695f796990f78c07e61d"
|
||||
"hash": "f20997bae03ef093e34de765f0ee766aaf00426de6b978ee6957f9b8a00daeae"
|
||||
}
|
||||
Reference in New Issue
Block a user