Reimplemented access and refresh tokens.
This commit is contained in:
@@ -3,7 +3,7 @@ use sqlx::PgPool;
|
||||
|
||||
use super::{AuthScheme, Authorizer, Principal};
|
||||
use crate::{
|
||||
crypto::hash_secret,
|
||||
domain::Secret,
|
||||
repository::{self, RepositoryError},
|
||||
};
|
||||
|
||||
@@ -32,8 +32,8 @@ where
|
||||
) -> Result<Principal<Self>, Self::Error> {
|
||||
let pool = PgPool::from_ref(state);
|
||||
|
||||
let token_hash = hash_secret(&credentials.0);
|
||||
let token = repository::tokens::get_by_access_token_hash(&pool, &token_hash)
|
||||
let token_hash = Secret::from(credentials.0).hash();
|
||||
let token = repository::tokens::get_access_token_by_hash(&pool, &token_hash)
|
||||
.await
|
||||
.map_err(BearerError::Repository)?
|
||||
.ok_or(BearerError::InvalidCredentials)?;
|
||||
|
||||
Reference in New Issue
Block a user