simple Log In endpoint without encryption

This commit is contained in:
2025-09-22 23:58:07 +02:00
parent 3450c216c0
commit 007071cf12
14 changed files with 680 additions and 60 deletions

View File

@@ -3,13 +3,15 @@ use axum::response::IntoResponse;
use axum::http::StatusCode;
use crate::rooms::extractor::UpdateRoomPayload;
use crate::utils::db_pool::*;
use std::sync::Arc;
use r2d2::{Pool};
use r2d2_sqlite::SqliteConnectionManager;
use dashmap::DashMap;
use rusqlite::params;
use crate::utils::db_pool::*;
pub async fn hello_rooms() -> String {
@@ -29,14 +31,12 @@ pub async fn fake_room_update(
}
pub async fn fake_db_update(
State(hotel_pools): State<HotelPools>,
State(state): State<AppState>,
Path(room_id): Path<i32>,
UpdateRoomPayload(payload): UpdateRoomPayload,
) -> impl IntoResponse {
let pool = hotel_pools.get_pool(payload.hotel_id);
let pool = state.hotel_pools.get_pool(payload.hotel_id);
let conn = match pool.get() {
Ok(conn) => conn,
Err(err) => return (StatusCode::INTERNAL_SERVER_ERROR, format!("Pool error: {err}")),
@@ -57,23 +57,9 @@ pub async fn fake_db_update(
}
/*
//fake db handler
pub async fn update_room(UpdateRoomPayload(payload): UpdateRoom) -> impl IntoResponse {
match fake_db_update(&payload.token, payload.room_id, &payload.status).await {
Ok(msg) => msg,
Err(err) => format!("Error: {}", err),
}
struct RoomRequest {
item_id: i32,
item_amount: i32,
token: String,
}
async fn fake_db_update(token: &str, room_id: i32, status: &str) -> Result<String, String> {
// Pretend we check the token in the DB
if token != "valid_token" {
return Err("Invalid token".into());
}
// Pretend we update the room status in the DB
Ok(format!("Room {} updated to '{}'", room_id, status))
}
*/