Make async-trait required for backend only

This commit is contained in:
Ethan Girouard 2024-05-18 18:51:59 -04:00
parent eb4dcd4776
commit 9a462d5ee9
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146
2 changed files with 10 additions and 2 deletions

View File

@ -32,7 +32,7 @@ tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5", optional = true, features = ["fs"] } tower-http = { version = "0.5", optional = true, features = ["fs"] }
thiserror = "1.0.57" thiserror = "1.0.57"
tower-sessions-redis-store = { version = "0.11", optional = true } tower-sessions-redis-store = { version = "0.11", optional = true }
async-trait = "0.1.79" async-trait = { version = "0.1.79", optional = true }
axum-login = { version = "0.14.0", optional = true } axum-login = { version = "0.14.0", optional = true }
log = { version = "0.4.21", optional = true } log = { version = "0.4.21", optional = true }
flexi_logger = { version = "0.28.0", optional = true, default-features = false } flexi_logger = { version = "0.28.0", optional = true, default-features = false }
@ -64,6 +64,7 @@ ssr = [
"tower", "tower",
"tower-http", "tower-http",
"tower-sessions-redis-store", "tower-sessions-redis-store",
"async-trait",
"axum-login", "axum-login",
"log", "log",
"flexi_logger", "flexi_logger",

View File

@ -1,10 +1,17 @@
use async_trait::async_trait;
use axum_login::{AuthnBackend, AuthUser, UserId}; use axum_login::{AuthnBackend, AuthUser, UserId};
use crate::users::UserCredentials; use crate::users::UserCredentials;
use leptos::server_fn::error::ServerFnErrorErr; use leptos::server_fn::error::ServerFnErrorErr;
use crate::models::User; use crate::models::User;
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(feature = "ssr")] {
use async_trait::async_trait;
}
}
impl AuthUser for User { impl AuthUser for User {
type Id = i32; type Id = i32;