Initial commit

This commit is contained in:
2024-09-01 06:20:49 +03:00
parent bd61f5d591
commit 9263c396a1
81 changed files with 1494 additions and 1521 deletions

View File

@@ -197,6 +197,29 @@ pub async fn login_finish(
Ok(credentials)
}
#[tracing::instrument]
pub async fn offline_auth(
name: &str,
exec: impl sqlx::Executor<'_, Database = sqlx::Sqlite> + Copy,
) -> crate::Result<Credentials> {
let random_uuid = Uuid::new_v4();
let access_token = "null".to_string();
let refresh_token = "null".to_string();
let credentials = Credentials {
id: random_uuid,
username: name.to_string(),
access_token: access_token,
refresh_token: refresh_token,
expires: Utc::now() + Duration::days(365 * 99),
active: true,
};
credentials.upsert(exec).await?;
Ok(credentials)
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Credentials {
pub id: Uuid,