mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 23:07:54 +00:00
20 lines
484 B
Rust
20 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,
|
|
}
|