From 0ce17fe805a3a891ffd531e4720b721ff0ae6ab2 Mon Sep 17 00:00:00 2001 From: schn33fuchs Date: Fri, 24 Apr 2026 19:53:43 +0200 Subject: [PATCH] Routes for auth handling Also db and structs are now identical --- backend/src/models.rs | 4 ++-- backend/src/router.rs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/src/models.rs b/backend/src/models.rs index 49d877c..0a5baac 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -30,8 +30,8 @@ pub struct TicketResponse { #[derive(Deserialize, Serialize, PartialEq, Debug)] pub struct User { pub id: i16, - pub first_name: String, pub last_name: String, + pub first_name: String, pub is_admin: bool, pub pwd: String, } @@ -67,8 +67,8 @@ pub struct LoginScheme { #[derive(Deserialize, Serialize, Debug, sqlx::FromRow)] pub struct LoginModel { pub id: i16, - pub first_name: String, pub last_name: String, + pub first_name: String, pub is_admin: bool, pub pwd: String, } diff --git a/backend/src/router.rs b/backend/src/router.rs index 6179a61..a16fa97 100644 --- a/backend/src/router.rs +++ b/backend/src/router.rs @@ -7,7 +7,10 @@ use axum::{ use crate::{ AppState, - handlers::ticket::{create_ticket, delete_ticket, edit_ticket, get_ticket_by_id, get_tickets}, + handlers::{ + auth::{create_user, login, logout}, + ticket::{create_ticket, delete_ticket, edit_ticket, get_ticket_by_id, get_tickets}, + }, }; pub fn create_router(state: Arc) -> Router { @@ -20,5 +23,8 @@ pub fn create_router(state: Arc) -> Router { .delete(delete_ticket) .patch(edit_ticket), ) + .route("/api/register", post(create_user)) + .route("/api/login", post(login)) + .route("/api/logout", get(logout)) .with_state(state) }