refactor: restructure code
This commit is contained in:
parent
ebe2f86a2c
commit
eb86945008
@ -1,2 +0,0 @@
|
||||
pub mod utils;
|
||||
|
@ -1,7 +1,11 @@
|
||||
use crate::auth::utils::hash_plain_password_with_salt;
|
||||
use crate::models::{Area, Role, Token, User};
|
||||
use crate::utils::{password_help, ApplicationError};
|
||||
use crate::{auth, filters};
|
||||
use crate::{
|
||||
filters,
|
||||
models::{Area, Role, Token, User},
|
||||
utils::{
|
||||
auth::{generate_salt_and_hash_plain_password, hash_plain_password_with_salt},
|
||||
password_help, ApplicationError,
|
||||
},
|
||||
};
|
||||
use actix_web::HttpResponse;
|
||||
use rinja::Template;
|
||||
use sqlx::PgPool;
|
||||
@ -117,7 +121,7 @@ async fn handle_password_change_request(
|
||||
return Ok(HttpResponse::BadRequest().body("Passwörter stimmen nicht überein."));
|
||||
}
|
||||
|
||||
let (hash, salt) = auth::utils::generate_salt_and_hash_plain_password(password).unwrap();
|
||||
let (hash, salt) = generate_salt_and_hash_plain_password(password).unwrap();
|
||||
|
||||
User::update(
|
||||
pool,
|
||||
|
@ -3,7 +3,7 @@ use actix_web::{web, HttpMessage, HttpRequest, HttpResponse, Responder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::{auth::utils::hash_plain_password_with_salt, models::User};
|
||||
use crate::{models::User, utils::auth::hash_plain_password_with_salt};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct LoginForm {
|
||||
|
@ -4,15 +4,9 @@ use serde::Deserialize;
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::{
|
||||
endpoints::{assignment::PlanEventPersonalTablePartialTemplate, vehicle_assignment::PlanVehiclesPartialTemplate},
|
||||
models::{Assignment, Availabillity, Event, Function, Role, User, Vehicle, VehicleAssignement},
|
||||
utils::{
|
||||
event_planning_template::{
|
||||
generate_availabillity_assignment_list, generate_status_whether_staff_is_required,
|
||||
generate_vehicles_assigned_and_available,
|
||||
},
|
||||
ApplicationError,
|
||||
},
|
||||
endpoints::vehicle_assignment::PlanVehiclesPartialTemplate,
|
||||
models::{Event, Role, User, Vehicle, VehicleAssignement},
|
||||
utils::{event_planning_template::generate_vehicles_assigned_and_available, ApplicationError},
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -16,7 +16,6 @@ use sqlx::{Pool, Postgres};
|
||||
use crate::postgres_session_store::SqlxPostgresqlSessionStore;
|
||||
use crate::utils::manage_commands::{handle_command, parse_args};
|
||||
|
||||
mod auth;
|
||||
mod endpoints;
|
||||
mod middleware;
|
||||
mod models;
|
||||
|
@ -36,26 +36,6 @@ impl Vehicle {
|
||||
Ok(vehicles)
|
||||
}
|
||||
|
||||
pub async fn read_all_assignable_for_event(pool: &PgPool, event_id: i32) -> Result<Vec<Vehicle>> {
|
||||
let records = query!(r#"
|
||||
SELECT *
|
||||
FROM vehicle
|
||||
|
||||
;"#).fetch_all(pool).await?;
|
||||
|
||||
let vehicles = records
|
||||
.into_iter()
|
||||
.map(|v| Vehicle {
|
||||
id: v.id,
|
||||
radio_call_name: v.radiocallname,
|
||||
station: v.station,
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(vehicles)
|
||||
}
|
||||
|
||||
|
||||
pub async fn read(pool: &PgPool, id: i32) -> Result<Option<Vehicle>> {
|
||||
let record = query!("SELECT * FROM vehicle WHERE id = $1;", id)
|
||||
.fetch_optional(pool)
|
||||
|
@ -23,3 +23,4 @@ pub fn hash_plain_password_with_salt(plain: &str, salt_string: &str) -> Result<S
|
||||
|
||||
Ok(hash)
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ use std::{
|
||||
use sqlx::{Pool, Postgres};
|
||||
|
||||
use crate::{
|
||||
auth::utils::generate_salt_and_hash_plain_password,
|
||||
models::{Function, Role, User},
|
||||
utils::auth::generate_salt_and_hash_plain_password,
|
||||
};
|
||||
|
||||
pub enum Command {
|
||||
|
@ -1,9 +1,10 @@
|
||||
mod application_error;
|
||||
pub mod auth;
|
||||
pub mod email;
|
||||
pub mod event_planning_template;
|
||||
pub mod manage_commands;
|
||||
pub mod password_help;
|
||||
pub mod token_generation;
|
||||
pub mod event_planning_template;
|
||||
mod application_error;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test_helper;
|
||||
|
Loading…
x
Reference in New Issue
Block a user