summaryrefslogtreecommitdiff
path: root/src/login/repo
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-03 23:30:42 -0400
committerKit La Touche <kit@transneptune.net>2024-10-03 23:30:42 -0400
commitd50b1b56c011c03c7d8a95242af404b727e91a80 (patch)
treeefe3408f6a8ef669981826d1a29d16a24b460d89 /src/login/repo
parent30c13478d61065a512f5bc8824fecbf2ee6afc81 (diff)
parent7f12fd41c2941a55a6437f24e4f780104a718790 (diff)
Merge branch 'main' into feature-frontend
Diffstat (limited to 'src/login/repo')
-rw-r--r--src/login/repo/auth.rs53
-rw-r--r--src/login/repo/mod.rs1
2 files changed, 0 insertions, 54 deletions
diff --git a/src/login/repo/auth.rs b/src/login/repo/auth.rs
deleted file mode 100644
index 3033c8f..0000000
--- a/src/login/repo/auth.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use sqlx::{sqlite::Sqlite, SqliteConnection, Transaction};
-
-use crate::{
- password::StoredHash,
- repo::login::{self, Login},
-};
-
-pub trait Provider {
- fn auth(&mut self) -> Auth;
-}
-
-impl<'c> Provider for Transaction<'c, Sqlite> {
- fn auth(&mut self) -> Auth {
- Auth(self)
- }
-}
-
-pub struct Auth<'t>(&'t mut SqliteConnection);
-
-impl<'t> Auth<'t> {
- // Retrieves a login by name, plus its stored password hash for
- // verification. If there's no login with the requested name, this will
- // return [None].
- pub async fn for_name(
- &mut self,
- name: &str,
- ) -> Result<Option<(Login, StoredHash)>, sqlx::Error> {
- let found = sqlx::query!(
- r#"
- select
- id as "id: login::Id",
- name,
- password_hash as "password_hash: StoredHash"
- from login
- where name = $1
- "#,
- name,
- )
- .map(|rec| {
- (
- Login {
- id: rec.id,
- name: rec.name,
- },
- rec.password_hash,
- )
- })
- .fetch_optional(&mut *self.0)
- .await?;
-
- Ok(found)
- }
-}
diff --git a/src/login/repo/mod.rs b/src/login/repo/mod.rs
deleted file mode 100644
index 0e4a05d..0000000
--- a/src/login/repo/mod.rs
+++ /dev/null
@@ -1 +0,0 @@
-pub mod auth;