feat: event management and websocket for updates

This commit is contained in:
Andrew Rioux
2025-02-22 16:04:15 -05:00
parent 005048f1ce
commit faaa4d2d1a
48 changed files with 1409 additions and 204 deletions
+14 -9
View File
@@ -1,3 +1,4 @@
use axum_extra::extract::cookie::CookieJar;
use leptos::{prelude::*, server_fn::error::NoCustomError};
use leptos_axum::{extract, ResponseOptions};
use pbkdf2::{
@@ -196,15 +197,10 @@ pub async fn destroy_auth_session() -> Result<(), ServerFnError> {
Ok(())
}
pub async fn get_auth_session() -> Result<Option<User>, ServerFnError> {
use axum_extra::extract::cookie::CookieJar;
println!("In get auth session");
let owner = leptos::prelude::Owner::current().unwrap();
let db = crate::db::get_db()?;
let jar = extract::<CookieJar>().await?;
pub async fn get_auth_session_inner(
db: SqlitePool,
jar: CookieJar
) -> Result<Option<User>, crate::error::Error> {
let Some(cookie) = jar.get(SESSION_ID_KEY) else {
return Ok(None);
};
@@ -252,3 +248,12 @@ pub async fn get_auth_session() -> Result<Option<User>, ServerFnError> {
Ok(user)
}
pub async fn get_auth_session() -> Result<Option<User>, ServerFnError> {
let db = crate::db::get_db()?;
let jar = extract::<CookieJar>().await?;
get_auth_session_inner(db, jar)
.await
.map_err(Into::into)
}