Session Auth Axum with Workspaces #3584
-
Hello, I'm working on an app and am trying to follow the "Session Auth Axum" example however done in workspaces, however I'm having an issue with ssr and non-ssr. In Workspaces in the Cargo.toml I have this: # SSR things
axum_session_auth = { workspace = true, optional = true }
axum_session = { workspace = true, optional = true }
axum_session_surreal = { workspace = true, optional = true }
bcrypt = { workspace = true, optional = true }
async-trait = { workspace = true, optional = true }
surrealdb = { workspace = true, optional = true }
[features]
default = []
hydrate = ["leptos/hydrate"]
ssr = [
"leptos/ssr",
"leptos_meta/ssr",
"leptos_router/ssr",
"dep:leptos_axum",
"dep:axum_session_surreal",
"dep:axum_session_auth",
"dep:axum_session",
"dep:async-trait",
"dep:surrealdb",
"dep:bcrypt",
] The issue occurs in my "auth" file in the "app" workspace folder. #[server(Login, "/api")]
pub async fn login(
username: String,
password: String,
remember: Option<String>,
) -> Result<(), ServerFnError> {
use crate::models::user::{User, UserPasshash};
use crate::ssr::{auth, pool};
use bcrypt::verify;
let db = pool()?;
let auth = auth()?;
let (user, UserPasshash(expected_passhash)) =
User::get_from_username_with_passhash(username, &db)
.await
.ok_or_else(|| ServerFnError::new("User does not exist."))?;
match verify(password, &expected_passhash)? {
true => {
auth.login_user(user.id);
auth.remember_user(remember.is_some());
leptos_axum::redirect("/");
Ok(())
}
false => Err(ServerFnError::ServerError(
"Invalid Username or Password.".to_string(),
)),
}
} It's saying that it cannot find the imports from ssr which would be an exact copy of this: However in the app folder of workspaces. Shouldn't I be able to access those ssr functions inside a server function or am I perhaps missing something? Thanks for any assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Just trying to provide more information here.
|
Beta Was this translation helpful? Give feedback.
-
It would be lovely if I read the thaw SSR requirements and followed them. Sorry for any wasted time. This inevitably fixed my issue. |
Beta Was this translation helpful? Give feedback.
It would be lovely if I read the thaw SSR requirements and followed them. Sorry for any wasted time. This inevitably fixed my issue.
https://thawui.vercel.app/guide/server-sider-rendering