ezidam: apps: archive, and revoke refresh tokens associated with app
This commit is contained in:
parent
956f28f7e5
commit
e06bd31b4c
11 changed files with 159 additions and 2 deletions
5
crates/database/queries/apps/archive.sql
Normal file
5
crates/database/queries/apps/archive.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
update apps
|
||||
|
||||
set is_archived = 1
|
||||
|
||||
where id is ?
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
update refresh_tokens
|
||||
|
||||
set revoked_at = CURRENT_TIMESTAMP
|
||||
|
||||
where app is ?
|
||||
and revoked_at is null
|
||||
|
|
@ -100,6 +100,16 @@
|
|||
},
|
||||
"query": "update apps\n\nset secret = ?\n\nwhere id is ?"
|
||||
},
|
||||
"2d562e7b19d7d8303a0e79d143d25fd68743ae30d1ec0b0ca5c7dfc367fdf357": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
}
|
||||
},
|
||||
"query": "update apps\n\nset is_archived = 1\n\nwhere id is ?"
|
||||
},
|
||||
"37681902a5f5d87492812a525a6488e75d20c1c436a3ba2c5aa3f54da62fe861": {
|
||||
"describe": {
|
||||
"columns": [
|
||||
|
|
@ -508,6 +518,16 @@
|
|||
},
|
||||
"query": "update settings\n\nset url = ?\n\nwhere id is 0\n"
|
||||
},
|
||||
"93b15a942a6c7db595990f00e14fde26d6d36b8c8de9935179d41f6c7c755978": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Right": 1
|
||||
}
|
||||
},
|
||||
"query": "update refresh_tokens\n\nset revoked_at = CURRENT_TIMESTAMP\n\nwhere app is ?\n and revoked_at is null"
|
||||
},
|
||||
"9f1885c4786f73335b4d614f562bb7cad49c91bfe7f084d8c25c6c571673ab90": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
|
|
|
|||
|
|
@ -136,4 +136,13 @@ impl Apps {
|
|||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
|
||||
pub async fn archive(conn: impl SqliteExecutor<'_>, id: &str) -> Result<Option<()>, Error> {
|
||||
let query: SqliteQueryResult = sqlx::query_file!("queries/apps/archive.sql", id)
|
||||
.execute(conn)
|
||||
.await
|
||||
.map_err(handle_error)?;
|
||||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,4 +96,17 @@ impl RefreshTokens {
|
|||
|
||||
Ok((query.rows_affected() == 1).then_some(()))
|
||||
}
|
||||
|
||||
pub async fn revoke_all_for_app(
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
app: &str,
|
||||
) -> Result<Option<()>, Error> {
|
||||
let query: SqliteQueryResult =
|
||||
sqlx::query_file!("queries/refresh_tokens/revoke_all_for_app.sql", app)
|
||||
.execute(conn)
|
||||
.await
|
||||
.map_err(handle_error)?;
|
||||
|
||||
Ok((query.rows_affected() >= 1).then_some(()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue