Minor Bugfixes

This commit is contained in:
2026-04-28 20:42:18 +02:00
parent ce86d8bc8f
commit dac2d91213
7 changed files with 111 additions and 20 deletions

View File

@@ -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

View File

@@ -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,
}
}
}