You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
Handle legacy /logout
This commit is contained in:
@ -1557,6 +1557,18 @@
|
||||
},
|
||||
"query": "\n UPDATE oauth2_refresh_tokens\n SET next_token_id = $2\n WHERE id = $1\n "
|
||||
},
|
||||
"c53f3f064920f8516a14b384760e2c30f18ab6f099e468cf019fb4eaa0547637": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"nullable": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"query": "\n UPDATE compat_access_tokens\n SET deleted_at = NOW()\n WHERE token = $1 AND deleted_at IS NULL\n "
|
||||
},
|
||||
"d2f767218ec2489058db9a0382ca0eea20379c30aeae9f492da4ba35b66f4dc7": {
|
||||
"describe": {
|
||||
"columns": [],
|
||||
|
@ -129,7 +129,7 @@ pub async fn lookup_active_compat_access_token(
|
||||
Ok((token, user))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(conn, password))]
|
||||
#[tracing::instrument(skip(conn, password, token))]
|
||||
pub async fn compat_login(
|
||||
conn: impl Acquire<'_, Database = Postgres>,
|
||||
username: &str,
|
||||
@ -200,3 +200,27 @@ pub async fn compat_login(
|
||||
txn.commit().await.context("could not commit transaction")?;
|
||||
Ok((token, user))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn compat_logout(
|
||||
executor: impl PgExecutor<'_>,
|
||||
token: &str,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let res = sqlx::query!(
|
||||
r#"
|
||||
UPDATE compat_access_tokens
|
||||
SET deleted_at = NOW()
|
||||
WHERE token = $1 AND deleted_at IS NULL
|
||||
"#,
|
||||
token,
|
||||
)
|
||||
.execute(executor)
|
||||
.await
|
||||
.context("could not update compat access token")?;
|
||||
|
||||
match res.rows_affected() {
|
||||
1 => Ok(()),
|
||||
0 => anyhow::bail!("no row affected"),
|
||||
_ => anyhow::bail!("too many row affected"),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user