diff --git a/examples/session_auth_axum/Todos.db b/examples/session_auth_axum/Todos.db index df5f7158d..3f65a9407 100644 Binary files a/examples/session_auth_axum/Todos.db and b/examples/session_auth_axum/Todos.db differ diff --git a/examples/session_auth_axum/src/auth.rs b/examples/session_auth_axum/src/auth.rs index 6dc78c269..0a9c8caac 100644 --- a/examples/session_auth_axum/src/auth.rs +++ b/examples/session_auth_axum/src/auth.rs @@ -162,9 +162,7 @@ pub async fn login( let user: User = User::get_from_username(username, &pool) .await - .ok_or_else(|| { - ServerFnError::ServerError("User does not exist.".into()) - })?; + .ok_or_else(|| ServerFnError::new("User does not exist."))?; match verify(password, &user.password)? { true => { @@ -207,9 +205,7 @@ pub async fn signup( User::get_from_username(username, &pool) .await .ok_or_else(|| { - ServerFnError::ServerError( - "Signup failed: User does not exist.".into(), - ) + ServerFnError::new("Signup failed: User does not exist.") })?; auth.login_user(user.id); diff --git a/examples/session_auth_axum/src/main.rs b/examples/session_auth_axum/src/main.rs index a321729fd..9797d70d0 100644 --- a/examples/session_auth_axum/src/main.rs +++ b/examples/session_auth_axum/src/main.rs @@ -6,8 +6,8 @@ if #[cfg(feature = "ssr")] { use axum::{ response::{Response, IntoResponse}, routing::get, - extract::{Path, State, RawQuery}, - http::{Request, header::HeaderMap}, + extract::{Path, State}, + http::{Request}, body::Body as AxumBody, Router, }; @@ -21,12 +21,12 @@ if #[cfg(feature = "ssr")] { use axum_session::{SessionConfig, SessionLayer, SessionStore}; use axum_session_auth::{AuthSessionLayer, AuthConfig, SessionSqlitePool}; - async fn server_fn_handler(State(app_state): State, auth_session: AuthSession, path: Path, headers: HeaderMap, raw_query: RawQuery, + async fn server_fn_handler(State(app_state): State, auth_session: AuthSession, path: Path, request: Request) -> impl IntoResponse { log!("{:?}", path); - handle_server_fns_with_context(path, headers, raw_query, move || { + handle_server_fns_with_context( move || { provide_context(auth_session.clone()); provide_context(app_state.pool.clone()); }, request).await @@ -58,10 +58,11 @@ if #[cfg(feature = "ssr")] { let auth_config = AuthConfig::::default(); let session_store = SessionStore::::new(Some(pool.clone().into()), session_config).await.unwrap(); - sqlx::migrate!() + if let Err(e) = sqlx::migrate!() .run(&pool) - .await - .expect("could not run SQLx migrations"); + .await { + eprintln!("{e:?}"); + } // Explicit server function registration is no longer required // on the main branch. On 0.3.0 and earlier, uncomment the lines