about summary refs log tree commit diff stats
path: root/crates/rocie-server/src/api/set/unit.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:07:14 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-12-09 13:07:14 +0100
commitc91dce4f77ae12453203f0a28b91efb6533cc095 (patch)
tree4f50e755dff7f717d45309b08f9fe2c8c87f88bd /crates/rocie-server/src/api/set/unit.rs
parentchore(rocie-client): Regenerate (diff)
downloadserver-c91dce4f77ae12453203f0a28b91efb6533cc095.zip
feat(rocie-server): Implement basic user handling and authentication
Diffstat (limited to '')
-rw-r--r--crates/rocie-server/src/api/set/auth/unit.rs (renamed from crates/rocie-server/src/api/set/unit.rs)17
1 files changed, 12 insertions, 5 deletions
diff --git a/crates/rocie-server/src/api/set/unit.rs b/crates/rocie-server/src/api/set/auth/unit.rs
index 1671918..21d1e11 100644
--- a/crates/rocie-server/src/api/set/unit.rs
+++ b/crates/rocie-server/src/api/set/auth/unit.rs
@@ -1,3 +1,4 @@
+use actix_identity::Identity;
 use actix_web::{HttpResponse, Responder, Result, post, web};
 use serde::Deserialize;
 use utoipa::ToSchema;
@@ -26,11 +27,15 @@ struct UnitStub {
 #[utoipa::path(
     responses(
         (
-            status = 200,
+            status = OK,
             description = "Unit successfully registered in database",
             body = UnitId,
         ),
         (
+            status = UNAUTHORIZED,
+            description = "You did not login before calling this endpoint",
+        ),
+        (
             status = INTERNAL_SERVER_ERROR,
             description = "Server encountered error",
             body = String,
@@ -42,14 +47,16 @@ struct UnitStub {
 pub(crate) async fn register_unit(
     app: web::Data<App>,
     unit: web::Json<UnitStub>,
+    _user: Identity,
 ) -> Result<impl Responder> {
+    let unit = unit.into_inner();
     let mut ops = Operations::new("register unit");
 
     let unit = Unit::register(
-        unit.full_name_singular.clone(),
-        unit.full_name_plural.clone(),
-        unit.short_name.clone(),
-        unit.description.clone(),
+        unit.full_name_singular,
+        unit.full_name_plural,
+        unit.short_name,
+        unit.description,
         unit.unit_property,
         &mut ops,
     );