diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:07:14 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-12-09 13:07:14 +0100 |
| commit | c91dce4f77ae12453203f0a28b91efb6533cc095 (patch) | |
| tree | 4f50e755dff7f717d45309b08f9fe2c8c87f88bd /crates/rocie-server/src/api/get/unit.rs | |
| parent | chore(rocie-client): Regenerate (diff) | |
| download | server-c91dce4f77ae12453203f0a28b91efb6533cc095.zip | |
feat(rocie-server): Implement basic user handling and authentication
Diffstat (limited to '')
| -rw-r--r-- | crates/rocie-server/src/api/get/auth/unit.rs (renamed from crates/rocie-server/src/api/get/unit.rs) | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/rocie-server/src/api/get/unit.rs b/crates/rocie-server/src/api/get/auth/unit.rs index caafaa3..980d9c7 100644 --- a/crates/rocie-server/src/api/get/unit.rs +++ b/crates/rocie-server/src/api/get/auth/unit.rs @@ -1,3 +1,4 @@ +use actix_identity::Identity; use actix_web::{HttpResponse, Responder, Result, get, web}; use crate::{ @@ -17,6 +18,10 @@ use crate::{ body = Vec<Unit> ), ( + status = UNAUTHORIZED, + description = "You did not login before calling this endpoint", + ), + ( status = INTERNAL_SERVER_ERROR, description = "Server encountered error", body = String @@ -24,7 +29,7 @@ use crate::{ ), )] #[get("/units/")] -pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { +pub(crate) async fn units(app: web::Data<App>, _user: Identity) -> Result<impl Responder> { let all = Unit::get_all(&app).await?; Ok(HttpResponse::Ok().json(all)) @@ -39,6 +44,10 @@ pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { body = Vec<Unit> ), ( + status = UNAUTHORIZED, + description = "You did not login before calling this endpoint", + ), + ( status = INTERNAL_SERVER_ERROR, description = "Server encountered error", body = String @@ -55,6 +64,7 @@ pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { pub(crate) async fn units_by_property_id( app: web::Data<App>, id: web::Path<UnitPropertyIdStub>, + _user: Identity, ) -> Result<impl Responder> { let id = id.into_inner(); let all = Unit::get_all(&app) @@ -75,6 +85,10 @@ pub(crate) async fn units_by_property_id( body = Unit ), ( + status = UNAUTHORIZED, + description = "You did not login before calling this endpoint", + ), + ( status = NOT_FOUND, description = "Unit not found in database" ), @@ -95,6 +109,7 @@ pub(crate) async fn units_by_property_id( pub(crate) async fn unit_by_id( app: web::Data<App>, id: web::Path<UnitIdStub>, + _user: Identity, ) -> Result<impl Responder> { let id = id.into_inner(); |
