mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-21 19:29:49 -04:00
Collapse into Nix fixes.
This commit is contained in:
parent
58dc0eef3f
commit
e58819585e
@ -40,16 +40,28 @@ pub async fn handler(
|
||||
debug!("successfully authenticated user");
|
||||
// 1. Create a session identifier.
|
||||
let mut session = Session::new();
|
||||
session.insert("user_id", auth.user_id()).unwrap();
|
||||
session
|
||||
.insert("user_id", auth.user_id())
|
||||
.expect("Unable to insert user id into session");
|
||||
// 2. Store the session in the store.
|
||||
let cookie_value = session_store.store_session(session).await.unwrap().unwrap();
|
||||
let cookie_value = session_store
|
||||
.store_session(session)
|
||||
.await
|
||||
.expect("Unable to store session in session store")
|
||||
.expect("No session cookie created");
|
||||
let mut headers = HeaderMap::new();
|
||||
// 3. Construct the Session Cookie.
|
||||
let cookie = Cookie::build(storage::AXUM_SESSION_COOKIE_NAME, cookie_value)
|
||||
.same_site(SameSite::Strict)
|
||||
.secure(true)
|
||||
.finish();
|
||||
headers.insert(header::SET_COOKIE, cookie.to_string().parse().unwrap());
|
||||
headers.insert(
|
||||
header::SET_COOKIE,
|
||||
cookie
|
||||
.to_string()
|
||||
.parse()
|
||||
.expect("Unable to parse session cookie"),
|
||||
);
|
||||
// Respond with 200 OK
|
||||
(StatusCode::OK, headers, "Login Successful")
|
||||
} else {
|
||||
@ -67,7 +79,12 @@ impl From<AuthBasic> for storage::UserCreds {
|
||||
fn from(AuthBasic((id, pass)): AuthBasic) -> Self {
|
||||
Self {
|
||||
id: storage::UserId(id.clone()),
|
||||
pass: Secret::from_str(pass.clone().unwrap().as_str()).unwrap(),
|
||||
pass: Secret::from_str(
|
||||
pass.clone()
|
||||
.expect("No password provided in BasicAuth")
|
||||
.as_str(),
|
||||
)
|
||||
.expect("Unable to store pass in secret"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ make_fn!(num<StrIter, u32>,
|
||||
do_each!(
|
||||
_ => peek!(ascii_digit),
|
||||
n => consume_all!(ascii_digit),
|
||||
(u32::from_str(n).unwrap())
|
||||
(u32::from_str(n).expect("Invalid u32 number in string"))
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -23,7 +23,7 @@ use crate::{js_lib::get_element_by_id, service::AppService};
|
||||
fn get_error_dialog() -> HtmlDialogElement {
|
||||
get_element_by_id::<HtmlDialogElement>("error-dialog")
|
||||
.expect("error-dialog isn't an html dialog element!")
|
||||
.unwrap()
|
||||
.expect("No error-dialog element present")
|
||||
}
|
||||
|
||||
fn check_category_text_parses(unparsed: &str, error_text: &Signal<String>) -> bool {
|
||||
|
@ -22,7 +22,7 @@ use recipes;
|
||||
fn get_error_dialog() -> HtmlDialogElement {
|
||||
get_element_by_id::<HtmlDialogElement>("error-dialog")
|
||||
.expect("error-dialog isn't an html dialog element!")
|
||||
.unwrap()
|
||||
.expect("error-dialog element isn't present")
|
||||
}
|
||||
|
||||
fn check_recipe_parses(text: &str, error_text: &Signal<String>) -> bool {
|
||||
@ -139,9 +139,9 @@ pub fn Recipe<'ctx, G: Html>(cx: Scope<'ctx>, recipe_id: String) -> View<G> {
|
||||
// FIXME(jwall): This has too many unwrap() calls
|
||||
if let Some(recipe) = app_service
|
||||
.fetch_recipes_from_storage()
|
||||
.unwrap()
|
||||
.expect("Failed to fetch recipes from storage")
|
||||
.1
|
||||
.unwrap()
|
||||
.expect(&format!("No recipe counts for recipe id: {}", recipe_id))
|
||||
.get(&recipe_id)
|
||||
{
|
||||
let recipe = create_signal(cx, recipe.clone());
|
||||
|
@ -53,7 +53,7 @@ pub fn RecipeSelection<G: Html>(cx: Scope, props: RecipeCheckBoxProps) -> View<G
|
||||
input(type="number", class="item-count-sel", min="0", bind:value=count, name=name, on:change=move |_| {
|
||||
let mut app_service = app_service.clone();
|
||||
debug!(idx=%id, count=%(*count.get()), "setting recipe count");
|
||||
app_service.set_recipe_count_by_index(id.as_ref(), count.get().parse().unwrap());
|
||||
app_service.set_recipe_count_by_index(id.as_ref(), count.get().parse().expect("recipe count isn't a valid usize number"));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,17 @@ pub fn get_element_by_id<E>(id: &str) -> Result<Option<E>, Element>
|
||||
where
|
||||
E: JsCast,
|
||||
{
|
||||
match window().unwrap().document().unwrap().get_element_by_id(id) {
|
||||
match window()
|
||||
.expect("No window present")
|
||||
.document()
|
||||
.expect("No document in window")
|
||||
.get_element_by_id(id)
|
||||
{
|
||||
Some(e) => e.dyn_into::<E>().map(|e| Some(e)),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_storage() -> Result<Option<Storage>, JsValue> {
|
||||
window().unwrap().local_storage()
|
||||
window().expect("No Window Present").local_storage()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user