This commit is contained in:
Jonas Rabenstein 2026-08-13 03:04:13 +02:00
commit 961d6665b5
2 changed files with 211 additions and 657 deletions

View file

@ -14,11 +14,7 @@ pub fn hash_token(token: &str) -> Vec<u8> {
hasher.finalize().to_vec()
}
pub async fn create_session(
db: &PgPool,
athlete_id: i64,
token: &str,
) -> Result<()> {
pub async fn create_session(db: &PgPool, athlete_id: i64, token: &str) -> Result<()> {
let hash = hash_token(token);
sqlx::query(
@ -38,10 +34,7 @@ pub async fn create_session(
Ok(())
}
pub async fn athlete_for_session(
db: &PgPool,
token: &str,
) -> Result<Option<(i64, String)>> {
pub async fn athlete_for_session(db: &PgPool, token: &str) -> Result<Option<(i64, String)>> {
let hash = hash_token(token);
let row = sqlx::query(
@ -62,11 +55,9 @@ pub async fn athlete_for_session(
use sqlx::Row;
if let Some(row) = row {
let id: i64 =
row.try_get("id")?;
let id: i64 = row.try_get("id")?;
let name: String =
row.try_get("display_name")?;
let name: String = row.try_get("display_name")?;
sqlx::query(
r#"
@ -93,10 +84,7 @@ pub struct SessionAthlete {
pub access_token: String,
}
pub async fn session_athlete(
db: &PgPool,
token: &str,
) -> Result<Option<SessionAthlete>> {
pub async fn session_athlete(db: &PgPool, token: &str) -> Result<Option<SessionAthlete>> {
let hash = hash_token(token);
let row = sqlx::query(
@ -166,9 +154,7 @@ pub async fn last_synced_activity_time(
Ok(row.try_get("last_synced")?)
}
pub async fn delete_old_oauth_states(
db: &PgPool,
) -> Result<()> {
pub async fn delete_old_oauth_states(db: &PgPool) -> Result<()> {
sqlx::query(
r#"
DELETE FROM oauth_states

File diff suppressed because it is too large Load diff