Minor Bugfixes
This commit is contained in:
@@ -12,7 +12,11 @@ use axum_extra::extract::CookieJar;
|
||||
use jsonwebtoken::DecodingKey;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{AppState, cookie::jwt::decode_token, models::LoginModel};
|
||||
use crate::{
|
||||
AppState,
|
||||
cookie::jwt::decode_token,
|
||||
models::{LoginScheme, User},
|
||||
};
|
||||
|
||||
pub async fn validate_token(
|
||||
cookies: CookieJar,
|
||||
@@ -59,7 +63,7 @@ pub async fn validate_token(
|
||||
(StatusCode::UNAUTHORIZED, Json(error))
|
||||
})?;
|
||||
|
||||
let user = sqlx::query_as::<_, LoginModel>(r#"SELECT * FROM users WHERE id = $1"#)
|
||||
let user = sqlx::query_as::<_, User>(r#"SELECT * FROM users WHERE id = $1"#)
|
||||
.bind(uuid)
|
||||
.fetch_optional(&data.db)
|
||||
.await
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
pub struct Env {
|
||||
pub db_url: String,
|
||||
pub token_secret: String,
|
||||
pub origin: String
|
||||
pub origin: String,
|
||||
}
|
||||
|
||||
impl Env {
|
||||
pub fn load() -> Env {
|
||||
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
let token_secret = std::env::var("TOKEN_SECRET").expect("TOKEN_SECRET must be set");
|
||||
let origin = std::env::var("ORIGIN").expect("ORIGIN must be set")
|
||||
let origin = std::env::var("ORIGIN").expect("ORIGIN must be set");
|
||||
Env {
|
||||
db_url,
|
||||
token_secret,
|
||||
origin
|
||||
origin,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user