summaryrefslogtreecommitdiff
path: root/src/token/repo/auth.rs
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-10 13:26:15 -0400
committerKit La Touche <kit@transneptune.net>2024-10-10 13:26:15 -0400
commit03f8d9ad603a4e523a0e2a0e60ad62c8725f0875 (patch)
treeb01543c0c2dadbd4be17320d47fc2e3d2fdb280d /src/token/repo/auth.rs
parentefae871b1bdb1e01081a44218281950cf0177f3b (diff)
parentd173bc08f2b699f58c8cca752ff688ad46f33ced (diff)
Merge branch 'main' into wip/path-routing-for-channels
Diffstat (limited to 'src/token/repo/auth.rs')
-rw-r--r--src/token/repo/auth.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/token/repo/auth.rs b/src/token/repo/auth.rs
index b299697..ddb5136 100644
--- a/src/token/repo/auth.rs
+++ b/src/token/repo/auth.rs
@@ -1,6 +1,10 @@
use sqlx::{sqlite::Sqlite, SqliteConnection, Transaction};
-use crate::login::{self, password::StoredHash, Login};
+use crate::{
+ clock::DateTime,
+ event::{Instant, Sequence},
+ login::{self, password::StoredHash, History, Login},
+};
pub trait Provider {
fn auth(&mut self) -> Auth;
@@ -21,25 +25,33 @@ impl<'t> Auth<'t> {
pub async fn for_name(
&mut self,
name: &str,
- ) -> Result<Option<(Login, StoredHash)>, sqlx::Error> {
+ ) -> Result<Option<(History, StoredHash)>, sqlx::Error> {
let found = sqlx::query!(
r#"
select
id as "id: login::Id",
name,
- password_hash as "password_hash: StoredHash"
+ password_hash as "password_hash: StoredHash",
+ created_sequence as "created_sequence: Sequence",
+ created_at as "created_at: DateTime"
from login
where name = $1
"#,
name,
)
- .map(|rec| {
+ .map(|row| {
(
- Login {
- id: rec.id,
- name: rec.name,
+ History {
+ login: Login {
+ id: row.id,
+ name: row.name,
+ },
+ created: Instant {
+ at: row.created_at,
+ sequence: row.created_sequence,
+ },
},
- rec.password_hash,
+ row.password_hash,
)
})
.fetch_optional(&mut *self.0)