summaryrefslogtreecommitdiff
path: root/src/token/repo/token.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/token/repo/token.rs')
-rw-r--r--src/token/repo/token.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/token/repo/token.rs b/src/token/repo/token.rs
index 5f64dac..c592dcd 100644
--- a/src/token/repo/token.rs
+++ b/src/token/repo/token.rs
@@ -3,7 +3,7 @@ use uuid::Uuid;
use crate::{
clock::DateTime,
- login::{self, Login},
+ login::{self, History, Login},
token::{Id, Secret},
};
@@ -24,11 +24,12 @@ impl<'c> Tokens<'c> {
// be used to control expiry, until the token is actually used.
pub async fn issue(
&mut self,
- login: &Login,
+ login: &History,
issued_at: &DateTime,
) -> Result<Secret, sqlx::Error> {
let id = Id::generate();
let secret = Uuid::new_v4().to_string();
+ let login = login.id();
let secret = sqlx::query_scalar!(
r#"
@@ -39,7 +40,7 @@ impl<'c> Tokens<'c> {
"#,
id,
secret,
- login.id,
+ login,
issued_at,
)
.fetch_one(&mut *self.0)
@@ -127,7 +128,7 @@ impl<'c> Tokens<'c> {
select
token.id as "token_id: Id",
login.id as "login_id: login::Id",
- name as "login_name"
+ login.name as "login_name"
from login
join token on login.id = token.login
where token.secret = $1