diff --git a/nixin_farm_ssr/src/controllers/server.rs b/nixin_farm_ssr/src/controllers/server.rs index 1de9dda..97a7c80 100644 --- a/nixin_farm_ssr/src/controllers/server.rs +++ b/nixin_farm_ssr/src/controllers/server.rs @@ -10,6 +10,7 @@ use crate::{ models::_entities::servers::{ActiveModel, Column, Entity, Model}, views, }; +use crate::models::users; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Params { @@ -31,9 +32,14 @@ async fn load_item(ctx: &AppContext, id: i32) -> Result { #[debug_handler] pub async fn list( + auth: auth::JWT, ViewEngine(v): ViewEngine, State(ctx): State, ) -> Result { + // we only want to make sure user exists, so we name the variable + // with a `_` in front to remove the warning about unused variable + let _current_user = users::Model::find_by_pid(&ctx.db, &auth.claims.pid).await?; + let item = Entity::find() .order_by(Column::Id, Order::Desc) .all(&ctx.db) diff --git a/nixin_farm_ssr/src/controllers/service.rs b/nixin_farm_ssr/src/controllers/service.rs index 0684574..2b74353 100644 --- a/nixin_farm_ssr/src/controllers/service.rs +++ b/nixin_farm_ssr/src/controllers/service.rs @@ -10,6 +10,7 @@ use crate::{ models::_entities::services::{ActiveModel, Column, Entity, Model}, views, }; +use crate::models::users; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Params { @@ -33,6 +34,7 @@ async fn load_item(ctx: &AppContext, id: i32) -> Result { #[debug_handler] pub async fn list( + _user: auth::ApiToken, ViewEngine(v): ViewEngine, State(ctx): State, ) -> Result {