From af3f5430a0b0f1834228b28fd89848959512e718 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 12 Sep 2022 15:30:19 +0200 Subject: Use configuration for environment variables --- src/models/auth.rs | 2 +- src/models/model.rs | 6 +++--- src/models/user.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/models') diff --git a/src/models/auth.rs b/src/models/auth.rs index 36a0175..8a70244 100644 --- a/src/models/auth.rs +++ b/src/models/auth.rs @@ -40,7 +40,7 @@ pub struct LoginCredentials { } static KEYS: Lazy = Lazy::new(|| { - let secret = std::env::var("JWT_SECRET").expect("JWT_SECRET must be set"); + let secret = &crate::config::CONFIG.jwt_secret; Keys::new(secret.as_bytes()) }); diff --git a/src/models/model.rs b/src/models/model.rs index 5b47f5c..f686192 100644 --- a/src/models/model.rs +++ b/src/models/model.rs @@ -1,4 +1,4 @@ -use crate::config::PAGE_LIMIT; +use crate::config::CONFIG; use crate::db::get_client; use crate::errors::AppError; @@ -163,8 +163,8 @@ impl Model { GROUP BY models.id, users.id LIMIT $1 OFFSET $2 "#, - PAGE_LIMIT, - PAGE_LIMIT * page + CONFIG.page_limit, + CONFIG.page_limit * page ) .fetch_all(pool) .await?; diff --git a/src/models/user.rs b/src/models/user.rs index 22bd130..55abc97 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -1,4 +1,4 @@ -use crate::config::PAGE_LIMIT; +use crate::config::CONFIG; use crate::db::get_client; use crate::errors::AppError; @@ -121,8 +121,8 @@ impl User { r#"SELECT id, email, username, is_staff FROM users LIMIT $1 OFFSET $2 "#, - PAGE_LIMIT, - PAGE_LIMIT * page + CONFIG.page_limit, + CONFIG.page_limit * page ) .fetch_all(pool) .await?; -- cgit v1.2.3-71-g8e6c