use rusqlite::{named_params, params, OptionalExtension, Params};
use crate::{
+ consts,
hash::{hash, verify_password},
model,
- consts,
};
const CURRENT_DB_VERSION: u32 = 1;
config::Config,
consts,
data::{asynchronous, db},
- email,
- model,
- utils,
+ email, model, utils,
};
mod api;
let (id,) = path.into_inner();
let user = match get_current_user(&req, connection.clone()).await {
Some(u) => u,
- None =>
+ None => {
return Ok(MessageTemplate {
user: None,
message: "Cannot edit a recipe without being logged in",
- }.to_response())
+ }
+ .to_response())
+ }
};
let recipe = connection.get_recipe_async(id).await?;
if recipe.user_id != user.id {
return Ok(MessageTemplate {
message: "Cannot edit a recipe you don't own",
- user: Some(user)
- }.to_response())
+ user: Some(user),
+ }
+ .to_response());
}
let recipes = connection.get_all_recipe_titles_async().await?;
) -> Result<HttpResponse> {
let user = match get_current_user(&req, connection.clone()).await {
Some(u) => u,
- None =>
+ None => {
return Ok(MessageTemplate {
message: "Cannot create a recipe without being logged in",
- user: None
- }.to_response())
+ user: None,
+ }
+ .to_response())
+ }
};
let recipe_id = connection.create_recipe_async(user.id).await?;