mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-12 08:40:11 +00:00
21 lines
484 B
Rust
21 lines
484 B
Rust
|
|
pub async fn legacy_token_auth(
|
||
|
|
pool: &sqlx::postgres::PgPool,
|
||
|
|
token: &str,
|
||
|
|
) -> anyhow::Result<Option<i32>> {
|
||
|
|
let mut system: Vec<LegacyTokenDbResponse> =
|
||
|
|
sqlx::query_as("select id from systems where token = $1")
|
||
|
|
.bind(token)
|
||
|
|
.fetch_all(pool)
|
||
|
|
.await?;
|
||
|
|
Ok(if let Some(system) = system.pop() {
|
||
|
|
Some(system.id)
|
||
|
|
} else {
|
||
|
|
None
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(sqlx::FromRow)]
|
||
|
|
struct LegacyTokenDbResponse {
|
||
|
|
id: i32,
|
||
|
|
}
|